题解
2023-08-20 14:58:13
发布于:广东
24阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
struct stu {
string name;
int score;
bool operator<(stu other) const {
if (score == other.score) {
return name < other.name;
}
return score > other.score;
}
};
int main() {
int n;
cin >> n;
vector<stu> students(n);
for (int i = 0; i < n; ++i) {
cin >> students[i].name >> students[i].score;
}
sort(students.begin(), students.end());
for (stu student : students) {
cout << student.name << " " << student.score << endl;
}
return 0;
}
结构体+排序,不会还没有人不会吧
这里空空如也
有帮助,赞一个