解题思路:
注意事项:
参考代码:
#include <bits/stdc++.h> using namespace std; struct u { int k; string str; }; struct u A[30]; bool cmp(u x1,u x2) { if(x1.k==x2.k) return x1.str<x2.str; return x1.k>x2.k; } int main() { int e,pp=0; cin>>e; for(int i=1; i<=e; i++) { cin>>A[i].str; cin>>A[i].k; } sort(A,A+e+1,cmp); for(int i=0; i<e; i++) { cout<<A[i].str<<" "; cout<<A[i].k<<endl; } return 0; }
0.0分
1 人评分