Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
455 | 邓小龙 | 成绩排序 | C++ | Accepted | 0 MS | 272 KB | 553 | 2022-08-20 12:58:24 |
#include<iostream> #include<cstring> #include<algorithm> using namespace std; struct chengji{ string name; int score; }; bool cmp(chengji x,chengji y){ if(x.score!=y.score) return x.score>y.score; else return x.name<y.name; } int main(){ int n; struct chengji stu[20]; cin>>n; for(int i=0;i<n;i++){ cin>>stu[i].name>>stu[i].score; } sort(stu,stu+n,cmp); for(int i=0;i<n;i++){ cout<<stu[i].name<<" "<<stu[i].score<<endl; } return 0; }