提交时间:2024-02-20 11:43:23

运行 ID: 41309

#include<iostream> #include<string> using namespace std; struct s{ string n; int s; }a[25]; bool cmp(s a,s b){ if(a.s !=b.s ){ return a.score>b.score; } else return a.n >b.n ; } int main() { int x; cin>>x; for(int i=1;i<=x;i++){ cin>>a[i].n >>a[i].s; } sort(a+1,a+1+x,cmp); for(int i=1;i<=x;i++){ cout<<a[i].n<<" "<<a[i].s<<endl ; } return 0; }