fiuwef
2024-01-26 11:00:22
发布于:四川
1阅读
0回复
0点赞
using namespace std;
const int N=310;
struct Stu{
int total,yuwen,shuxue,yingyu,id;
};
Stu s[N];
bool cmp(Stu a,Stu b)
{
if(a.total>b.total) return 1;
if(a.total==b.total&&a.yuwen>b.yuwen) return 1;
if(a.total==b.total&&a.yuwen==b.yuwen&&a.id<b.id) return 1;
return 0;
}
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>s[i].yuwen>>s[i].shuxue>>s[i].yingyu;
s[i].total=s[i].yuwen+s[i].shuxue+s[i].yingyu;
s[i].id=i;
}
sort(s+1,s+1+n,cmp);
for(int i=1;i<=5;i++)
{
cout<<s[i].id<<' '<<s[i].total<<endl;
}
}
这里空空如也
有帮助,赞一个