提交时间:2026-04-14 19:48:51
运行 ID: 436437
#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; }