结构体排序
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 305;
struct student {
int id;
int sum;
int yuwen;
}arr[N];
int n;
bool cmp(struct student s1,struct student s2) {
if (s1.sum != s2.sum) return s1.sum > s2.sum;
if (s1.yuwen != s2.yuwen) return s1.yuwen > s2.yuwen;
return s1.id < s2.id;
}
int main() {
cin >> n;
for (int i = 0;i < n;i++) {
int a,b,c;
cin >> a >> b >> c;
arr[i].id = i + 1;
arr[i].sum = a + b + c;
arr[i].yuwen = a;
}
sort(arr,arr + n,cmp);
for (int i = 0;i < 5;i++) {
cout << arr[i].id << ' ' << arr[i].sum << endl;
}
}