Jayling @ 2021-08-20 17:51:53
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
struct s{
string name;
int chinese;
int math;
int English;
int sum;
int c;
};
bool cmp(s a, s b){
if(a.sum!=b.sum){
return a.sum>b.sum;
}else{
a.c<b.c;
}
}
s stu[1004];
int main(){
int n, i;
cin>>n;
for(i=1;i<=n;i++){
cin>>stu[i].name>>stu[i].chinese>>stu[i].math>>stu[i].English;
stu[i].c = i;
stu[i].sum = stu[i].chinese+stu[i].math+stu[i].English;
}
sort(stu+1,stu+1+n,cmp);
cout<<stu[1].name<<" "<<stu[1].chinese<<" "<<stu[1].math<<" "<<stu[1].English;
return 0;
}
by Ninelife_Cat @ 2021-08-20 17:54:40
@Jayling
bool cmp(s a, s b){
if(a.sum!=b.sum){
return a.sum>b.sum;
}else{
//a.c<b.c;
return a.c<b.c;
}
}
by Jayling @ 2021-08-20 21:57:44
@Ninelife_Cat 感谢