主站
DreamJudge
院校信息
专业题库
模拟考试
机试真题
专业课程
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
1935569240
2024年3月6日 11:43
查找第K小数 题解:简单代码来了哦
P1383
回复 0
|
赞 0
|
浏览 260
#include<iostream> #include<algorithm> #include<string> using namespace std; int main() { int n,k; while (cin>>n) { int a[1005]; for (int i = 0; i &...
orderrr
2024年2月28日 17:49
查找第K小数 题解:可以利用数组坐标标记数组,然后从0遍历标记数组的值
P1383
回复 0
|
赞 0
|
浏览 245
#include <stdio.h> int main() { int n; while (scanf("%d", &n) != EOF) { int num[100000] = {0}; for (int i = 0; i < n; i++) { int k; scanf("%d", &k); num[k]++; } int index = 0; // 第几小 int k; scanf("%d", &k); ...
小李122333
2024年2月28日 17:11
查找第K小数 题解:C++ set容器自动去重
P1383
回复 0
|
赞 2
|
浏览 261
#include<bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { set<int> s; for (int i = 0; i < n; i++) { int x; cin >> x; s.insert(x); } int k; cin &...
DestinyCares+++
2024年2月22日 20:52
查找第K小数 题解:sort加优先队列
P1383
回复 0
|
赞 0
|
浏览 284
#include<iostream> #include<string> #include<queue> #include<algorithm> using namespace std; int a[1005]; int main(){ int n; while (cin>>n) { priority_queue<int, vector<int&g...
ZCD
2024年2月8日 18:03
查找第K小数 题解:
P1383
回复 0
|
赞 0
|
浏览 268
#include<iostream> #include<map> #include<algorithm> using namespace std; int main() { int n, m; while (cin >> n) { map<int, int>M; &nb...
小王桐学
2024年1月28日 22:15
查找第K小数 题解:C
P1383
回复 0
|
赞 1
|
浏览 256
数组进行从小到大排序,相同的数必相邻,数出第k个数即所求。 #include <stdio.h> #define N 1000 void Sort(int a[],int n) { int i,j,temp; for(i = 0; i < n-1; i++) for(j = 1; j < n-i; j++) if(a[j] < a[j-1]) { temp = a[j-1]; a[j-1] = a[j]; a[j] = temp; } } int ma...
fzh
2024年1月20日 08:14
查找第K小数 题解:
P1383
回复 0
|
赞 0
|
浏览 244
#include<stdio.h> int main() { int n; scanf("%d",&n); int array[1000]={0},k; for(int i=0;i<n;i++) scanf("%d",&array[i]); scanf("%d",&k); ...
小李122333
2024年1月11日 20:14
查找第K小数 题解:c++ map方法
P1383
回复 0
|
赞 2
|
浏览 395
#include <bits/stdc++.h> using namespace std; int main(){ int n,x,k,count; while(cin>>n){ count = 0; map<int,int> mp;//定义map for(int i=0;i<n;i++){ cin>>x; mp[x]++;//映射相当于mp[x]=mp[x]+1; } ...
C112233
2023年7月28日 16:28
查找第K小数 题解:
P1383
回复 0
|
赞 1
|
浏览 475
解法一:map<排名,数据>,数据输入完成后就进行排序,当当前数据与前一个数据相同时map不记录,不同时记录; #include <bits/stdc++.h> using namespace std; int main(){ int n; while(cin>>n){ map<int,int> maps; &...
jix::c
2023年5月4日 18:56
查找第K小数 题解:
P1383
回复 0
|
赞 0
|
浏览 732
第k小,会有重复的数字,需要去一下重,这里选择使用map去重,map也是内部有序的,所以可以直接进行输出。 for(auto x:mp) { k--; if(!k) { cout << x.first; return; } } AC代码 void slove() { cin >> n; map<int,int> mp; lp(i,1,n) { int x; cin >> x; mp[x]++; } int k; ...
1
2
3
题目
查找第K小数
题解数量
29
发布题解
热门题解
1
c 利用数组(可自动排序和去重,算法不是最好,但提供一种思路)
2
用set容器
3
P1383 解题思路分享
4
查找第K小数 题解:C++ set容器自动去重
5
查找第K小数 题解:c++ map方法
6
查找第K小数(C++) 题解:
7
查找第K小数 题解:
8
查找第K小数 题解:简单粗暴
9
1383查找第K小数(不是最好写法)
10
查找第K小数 题解:C