请写出代码
时间: 2024-02-28 17:57:02 浏览: 63
```c++
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct Student {
string id;
string name;
int math;
int c;
};
bool cmp(Student a, Student b) {
return a.c > b.c;
}
int main() {
int n;
cin >> n;
vector<Student> students(n);
for (int i = 0; i < n; i++) {
cin >> students[i].id >> students[i].name >> students[i].math >> students[i].c;
}
sort(students.begin(), students.end(), cmp);
for (int i = 0; i < n; i++) {
cout << students[i].id << " " << students[i].name << " " << students[i].math << " " << students[i].c << endl;
}
return 0;
}
```
阅读全文