SAS_Ghost @ 2023-10-31 13:14:01
只有第三个点WA掉了求助!!! 代码如下:
#include<bits/stdc++.h>
using namespace std;
int n,k,l[5000001];
void input(){
cin>>n>>k;
for(int i=0;i<n;i++){
scanf("%d",&l[i]);
}
}
void output(){
printf("%d\n",l[k]);
}
void qsort(int L,int R){
int i=L,j=R,mid=l[(L+R)/2];
while(i<=j){
while(l[i]<mid){
i++;
}
while(l[j]>mid){
j--;
}
if(i<=j){
swap(l[i],l[j]);
i++;j--;
}
}
if(k<j)qsort(L,j);
if(k>i)qsort(i,R);
}
int main(){
input();
qsort(0,n-1);
//sort(l,l+n-1);
output();
return 0;
}
by flame2024 @ 2023-10-31 13:41:03
main出错了!
by flame2024 @ 2023-10-31 13:42:52
要用scanf+printf+O2,就可以了,可以用sort,没必要自己写。
by turefalse @ 2023-10-31 13:47:40
@fd22wangzihan 感觉你写的太麻烦了
by SAS_Ghost @ 2023-11-01 12:58:16
@jipingan 为啥main错了???
by SAS_Ghost @ 2023-11-01 13:18:08
哎呀终于AC了是写快排的最后应该是k<=j和k>=i