Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
81240 sh25_zhangyy 期中考试成绩排序 C++ 通过 0 MS 244 KB 637 2026-01-04 15:42:51

Tests(1/1):


#include <iostream> #include <vector> #include <algorithm> using namespace std; struct Student { string name; int score; }; bool compare(const Student& a, const Student& b) { if (a.score != b.score) return a.score > b.score; return a.name < b.name; } int main() { int n; cin >> n; vector<Student> students(n); for (int i = 0; i < n; ++i) { cin >> students[i].name >> students[i].score; } sort(students.begin(), students.end(), compare); for (const auto& student : students) { cout << student.name << " " << student.score << endl; } return 0; }


测评信息: