Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
59728 | lihaocheng | 期中考试成绩排序 | C++ | Accepted | 0 MS | 252 KB | 455 | 2024-12-27 19:04:33 |
#include <bits/stdc++.h> using namespace std; struct r{ int s; string name; }; r a[61]; bool cmp(r x,r y){ if(x.s>y.s ){ return 1; } else if(x.s<y.s){ return 0; } else{ if(x.name<y.name){ return 1; } else return 0; } } int main(){ int n; cin>>n; for(int i=0;i<n;i++){ cin>>a[i].name>>a[i].s; } sort(a,a+n,cmp); for(int i=0;i<n;i++){ cout<<a[i].name<<" "<<a[i].s<<endl; } return 0; }