Xiaonao_Dali @ 2023-12-30 21:38:07
#include<bits/stdc++.h>
using namespace std;
bool cmp(int a,int b){
return a<b;
}
int main(){
int n,a[10005],k;
scanf("%d%d",&n,&k);
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
}
sort(a,a+n);
int len=unique(a,a+n)-a;
if(k<len){
printf("%d",a[k]);
}
else if(k>len){
printf("NO RESULT");
}
return 0;
}
by I_will_AKIOI @ 2023-12-30 21:42:23
a 数组开
by I_will_AKIOI @ 2023-12-30 21:43:16
#include<bits/stdc++.h>
using namespace std;
int n,a[5000005],k;
bool cmp(int a,int b){
return a<b;
}
int main(){
scanf("%d%d",&n,&k);
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
}
sort(a,a+n);
printf("%d",a[k]);
return 0;
}
by sulingfeng @ 2024-01-16 18:45:03
不用写cmp
by sulingfeng @ 2024-01-16 18:45:40
也不用写if else
by sulingfeng @ 2024-01-16 18:46:32
len也不需要呀