NYOJ871 比赛 stable_sort

2014-11-24 10:25:43 · 作者: · 浏览: 0

原题链接

stable_sort函数的用法。

#include 
  
   
#include 
   
     #include 
    
      #include 
     
       using namespace std; struct Node{ int num, sco; string name; }; bool cmp(Node a, Node b){ return a.sco > b.sco; } int main(){ int t, n; Node stu; cin >> t; while(t--){ cin >> n; vector
      
        vec; while(n--){ cin >> stu.num >> stu.name >> stu.sco; vec.push_back(stu); } stable_sort(vec.begin(), vec.end(), cmp); for(int i = 0; i != vec.size(); ++i) cout << vec[i].num << ' ' << vec[i].name << ' ' << vec[i].sco << endl; vec.clear(); } return 0; }