题解:
2023-07-25 15:26:10
发布于:浙江
12阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
struct student{
int yu;
int shu;
int ying;
int zong;
int xue;
}a[305];
bool cmp(student x,student y)
{
if(x.yuy.yu && x.zongy.zong)
{
return x.xue<y.xue;
}
if(x.zong==y.zong)
{
return x.yu>y.yu;
}
return x.zong>y.zong;
}
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+1+n,cmp);
if(n>=5)
{
for(int i=1;i<=5;i++)
{
cout<<a[i].xue<<" "<<a[i].zong<<endl;
}
}
else
{
for(int i=1;i<=n;i++)
{
cout<<a[i].xue<<" "<<a[i].zong<<endl;
}
}
}
这里空空如也
有帮助,赞一个