Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
436437 方相宜 【C5-9】成绩排序 C++ 通过 100 1 MS 260 KB 750 2026-04-14 19:48:51

Tests(10/10):


#include <iostream> #include <vector> #include <algorithm> using namespace std; struct Student { int id; int score; }; bool compareStudents(const Student &a, const Student &b) { return a.score > b.score; // 按分数降序排列 } int main() { int n; cin >> n; vector<Student> students(n); for (int i = 0; i < n; ++i) { cin >> students[i].score; students[i].id = i + 1; // 编号从1开始 } // 按分数排序 sort(students.begin(), students.end(), compareStudents); // 输出结果 for (int i = 0; i < n; ++i) { if (i != 0) cout << " "; cout << students[i].id; } cout << endl; return 0; }


测评信息: