用户:
原力开发查看:55 回复:7 评论:55 创建时间:2024-01-25T12:07:57
自己输入吧:


不要吵了,他写的程序不咋地,看我的:
#include<bits/stdc++.h>
using namespace std;
struct stu
{
int num;
int chinese;
int math;
int english;
int sum;
};
bool mysort(stu x,stu y)
{
if(x.sum>y.sum)
{
return true;
}
else if(x.sum==y.sum&&x.chinese>y.chinese)
{
return true;
}
else if(x.sum==y.sum&&x.chinese==y.chinese&&x.num<y.num)
{
return true;
}
else
{
return false;
}
}
int main(){
int n;
cin>>n;
stu a[300];
for(int i=1;i<=n;i++)
{
a[i].num=i;
cin>>a[i].chinese>>a[i].math>>a[i].english;
a[i].sum=a[i].chinese+a[i].math+a[i].english;
}
sort(a+1,a+n+1,mysort);
for(int i=1;i<=5;i++)
{
cout<<a[i].num<<" "<<a[i].sum<<endl;
}
return 0;
}
点赞0
评论