qwe1471900575 @ 2021-03-04 01:25:18
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <cstdio>
using namespace std;
struct student
{
int id;
int chinese;
int sum;
};
int cmp(student a, student b)//******
{
return a.sum > b.sum;
return a.chinese > b.chinese;
return a.id < b.id;
}
student a[350];
int main()
{
freopen("sb.in", "r", stdin);
freopen("sb.out", "w", stdout);
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
int math, english;
cin >> a[i].chinese >> math >> english;
a[i].sum = math + english + a[i].chinese;
a[i].id = i + 1;
}
sort(a, a + n, cmp);
for (int i = 0; i < 5; i++)
{
cout << a[i].id << " " << a[i].sum << endl;
}
return 0;
}
by One_Zzz6174 @ 2021-03-04 07:40:42
by One_Zzz6174 @ 2021-03-04 07:42:18
return a.sum != b.sum ? a.sum > b.sum : a.chinese != b.chinese ? a.chinese > b.chinese : a.id < b.id
by qwe1471900575 @ 2021-03-04 18:30:42
@One_Zzz
AC了谢谢