TPST @ 2022-10-19 23:57:07
#include<bits/stdc++.h>
using namespace std;
struct stu {
int sum;
int chinese;
int math;
int English;
int id;
};
stu a[301];
bool cmp(stu a,stu b){
if(a.sum>b.sum){
return true;
}else{
if(a.sum==b.sum&&a.chinese>b.chinese){
return true;
}else{
if(a.sum==b.sum&&a.chinese==b.chinese&&a.id<b.id){
return true;
}else{
return false;
}
}
}
}
int main(){
int n,i;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i].chinese>>a[i].math>>a[i].English;
}
a[i].sum=a[i].chinese+a[i].math+a[i].English;
a[i].id=i;
sort(a,a+n+1,cmp);
for(int i=1;i<=5;i++){
cout<<a[i].id<<a[i].sum<<endl;
}
return 0;
}
by Love_Elaina @ 2022-10-20 07:44:10
@TPST 你自己看看你的花括号打在哪里的,不RE才怪
for(int i=1;i<=n;i++){
cin>>a[i].chinese>>a[i].math>>a[i].English;
}
a[i].sum=a[i].chinese+a[i].math+a[i].English;
a[i].id=i;
by TPST @ 2022-10-21 12:14:03
@岛饰崂靶 感谢!