提交时间:2026-04-10 15:16:48

运行 ID: 87031

#include <iostream> #include <algorithm> #include <string> 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; } else { return a.name < b.name; } } int main() { int n; cin >> n; Student s[65]; for (int i = 0; i < n; i++) { cin >> s[i].name >> s[i].score; } sort(s, s + n, cmp); for (int i = 0; i < n; i++) { cout << s[i].name << " " << s[i].score << endl; } return 0; }