题解 | #你能活多少秒#
争夺前五名
http://www.nowcoder.com/practice/cd052308a1c44a88ad00255f312c3e14
用STL就好...要了解sort的底层吧,自己写的排序效率好像更高一点
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
int a;
vector<int> v;
cin>>a;
while(cin>>a)
v.push_back(a);
sort(v.begin(), v.end(),greater<int>());
cout<<v[0]<<" "<<v[1]<<" "<<v[2]<<" "<<v[3]<<" "<<v[4]<<" "<<endl;
}