用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;
}