```
#include<bits/stdc++.h>
using namespace std;
struct node
{
int xue;
int yu;
int shu;
int ying;
int zong;
}a[1000];
bool cmp(node x,node y)
{
if(x.zong!=y.zong) return x.zong>y.zong;
else if(x.yu!=y.yu) return x.yu>y.yu;
else return x.xue<y.xue;
}
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i].yu>>a[i].shu>>a[i].ying;
a[i].xue=i;
a[i].zong=a[i].yu+a[i].shu+a[i].ying;
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=5;i++)
{
cout<<a[i].xue<<" "<<a[i].zong<<endl;
}
return 0;
}
```
by yhldczh @ 2024-02-06 19:11:48
```cpp
else return x.xue_hao > y.xue_hao;
```
改成
```cpp
else return x.xue_hao < y.xue_hao;
```
就行了
by gotocspandbetter @ 2024-02-06 19:12:03
那么规定学号小的同学排在前面。
你仔细读读题吧。
by liuruiqing @ 2024-02-06 19:12:14
@[123uuu](/user/539712)
by gotocspandbetter @ 2024-02-06 19:12:16
@[gotocspandbetter](/user/1041003) 感谢dalao
by 123uuu @ 2024-02-07 12:50:43