...
2023-08-18 09:04:49
发布于:广东
13阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
struct student{
string name;
int score;
int id;
}s[35];
int cmp(student x , student y){
if(x.score == y.score) return x.id < y.id;
return x.score > y.score;
}
int main(){
int n;
cin >> n;
for(int i = 1;i <= n;i++){
cin >> s[i].name >> s[i].score;
s[i].id = i;
}
sort(s****+n+1,cmp);
for(int i = 1;i <= n;i++){
cout << s[i].name << ' ' << s[i].score << '\n';
}
return 0;
}
全部评论 1
easy
2023-08-19 来自 广东
0
有帮助,赞一个