文章
43
粉丝
180
获赞
21
访问
195.0k
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1010;
struct node
{
string name;
int c, m, e;
int sum;
}s[N];
bool cmp(node a, node b)
{
if (a.sum != b.sum) return a.sum > b.sum;
else if (a.c != b.c) return a.c > b.c;
else if (a.m != b.m) return a.m > b.m;
else return a.e > b.e;
}
int main()
{
int n;
cin >> n;
for (int i = 0; i < n; i ++ )
{
cin >> s[i].name >> s[i].c >> s[i].m >> s[i].e;
s[i].sum = s[i].c + s[i].m + s[i].e;
}
stable_sort(s, s + n, cmp);
for (int i = 0; i < n; i ++ )
cout << s[i].name << ' ' << s[i].c << ' ' << s[i].m << ' ' << s[i].e << endl;
return 0;
}
登录后发布评论
点赞哦点赞哦点赞哦点赞哦点赞哦点赞哦