文章
20
粉丝
412
获赞
12
访问
162.7k
#include <bits/stdc++.h>
using namespace std;
struct Record {
char s[10];
int score1, score2, score3;
}r[105];
bool cmp(Record a, Record b) {
int sum_a = a.score1 + a.score2 + a.score3;
int sum_b = b.score1 + b.score2 + b.score3;
return sum_a > sum_b;
}
int main() {
int n;
scanf("%d", &n);
for(int i = 0;i < n;i++)
scanf("%s %d %d %d", &r[i].s, &r[i].score1, &r[i].score2, &r[i].score3);
sort(r, r+n, cmp);
for(int i = 0;i < n;i++)
printf("%s %d %d %d\n", r[i].s, r[i].score1, r[i].score2, r[i].score3);
return 0;
}
登录后发布评论
感谢提醒~数据已修正