题解 | #寻找第K大#

寻找第K大

http://www.nowcoder.com/practice/e016ad9b7f0b45048c58a9f27ba618bf

int findKth(int* a, int aLen, int n, int K ) {
// write code here
int max, temp;//最大值和下标
int i,j;
for(j=0; j<K; j++)
{
max = 0;
for(i=1; i<n-j; i++)
{
if(a[max] < a[i])
max = i;
}
temp = a[max];
a[max] = a[i-1];
a[i-1] = temp;
//printf("%d\n",temp);
}
return temp;
}

全部评论

相关推荐

牛客48826091...:哥们胸肌挺好看
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务