舍叉叉予:C++里比sort更好的解法
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
vector<int> sourceInput;
int temp;
char c;
while ((cin>>temp).get(c))
{
sourceInput.push_back(temp);
if (c=='\n')
break;
}
int kth;
cin >> kth;
nth_element(sourceInput.begin(), sourceInput.end() - kth, sourceInput.end());
cout << *(sourceInput.end() - kth) << endl;
//system("pause");
return 0;
}
0 点赞 评论 收藏
分享
创作者周榜
更多
关注他的用户也关注了: