题目描述
https://www.acwing.com/problem/content/788/
C++ 代码
include[HTML_REMOVED]
include[HTML_REMOVED]
using namespace std;
int q[1000010],n,k;
void qsort(int q[],int l,int r)
{
if(l>=r) return;
int x=q[l],i=l-1,j=r+1;
while(i[HTML_REMOVED]x);
if(i<j) swap(q[i],q[j]);
}
qsort(q,l,j);
qsort(q,j+1,r);
}
int main()
{
scanf(“%d%d”,&n,&k);
for(int i=1;i<=n;i++)
scanf(“%d”,&q[i]);
qsort(q,1,n);
printf(“%d”,q[k]);
return 0;
}