- 成绩排序
key
- @ 2025-7-19 10:04:51
#include<bits/stdc++.h>
using namespace std;
struct Student {
string name;
int score;
}
bool cmp(Student a, Student b) {
if(a.score != b.score) return a.score > b.score;
return a.name < b.name;
}
int main() {
int n;
cin >> n;
vector students(n);
for(int i=0; i<n; i++) {
cin >> students[i].name >> students[i].score;
}
sort(students.begin(), students.end(), cmp);
for(auto s : students) {
cout << s.name << " " << s.score << endl;
}
return 0;
}
0 条评论
目前还没有评论...
信息
- ID
- 182
- 时间
- ms
- 内存
- MiB
- 难度
- 7
- 标签
- 递交数
- 86
- 已通过
- 18
- 上传者