题解
2023-08-15 01:12:30
发布于:广东
1阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
struct cj
{
int shu,chinese,maths,english,sum;
};
bool cmp(cj a,cj b)
{
if(a.sum > b.sum)
return true;
else if(a.sum < b.sum)
return false;
else if(a.chinese > b.chinese)
return true;
else if(a.chinese < b.chinese)
return false;
else
return a.shu < b.shu;
}
int main()
{
int n;
cin >> n;
cj a[n+1];
for(int i=1; i<=n; i++)
{
cin >> a[i].chinese >> a[i].maths >> a[i].english;
a[i].sum = a[i].chinese + a[i].maths + a[i].english;
a[i].shu = i;
}
sort(a, a+n+1, cmp);
for(int i=0; i<5; i++)
{
cout << a[i].shu << ' ' << a[i].sum << endl;
}
return 0;
}
这里空空如也
有帮助,赞一个