#include #include #include

using namespace std;

struct Student { int chinese; int math; int english; int total; int rank; };

bool compare(Student a, Student b) { return a.total > b.total; }

int main() { int N; cin >> N;

vector<Student> students(N);

for (int i = 0; i < N; i++) {
    cin >> students[i].chinese >> students[i].math >> students[i].english;
    students[i].total = students[i].chinese + students[i].math + students[i].english;
}

sort(students.begin(), students.end(), compare);

for (int i = 0; i < N; i++) {
    students[i].rank = i + 1;
    cout << students[i].chinese << " " << students[i].math << " " << students[i].english << " " << students[i].total << " " << students[i].rank << endl;
}

return 0;

原文地址: https://www.cveoy.top/t/topic/inq2 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录