1 #include <iostream> 2 #include <string> 3 #include <algorithm> 4 using namespace std; 5 struct node 6 { 7 string teamname; 8 int sum; 9 int time; 10 }Node[101]; 11 //自定义sort函数 12 int comp(node &a,node &b) 13 { 14 if(a.sum==b.sum) 15 return a.time<b.time; 16 else 17 return a.sum>b.sum; 18 } 19 20 int main() 21 { 22 int n,i,j; 23 cin>>n; 24 for(i=0;i<n;i++) 25 { 26 cin>>Node[i].teamname>>Node[i].sum>>Node[i].time; 27 } 28 sort(Node,Node+n,comp); //自定义一个sort函数 29 cout<<endl; 30 for(j=0;j<n;j++) 31 { 32 cout<<Node[j].teamname<<endl; 33 } 34 return 0; 35 }