william_20080118 @ 2020-07-01 15:06:41
#include<bits/stdc++.h>
using namespace std;
int n;
struct inf{
char name[8];
int Chi;
int mat;
int Eng;
int tot;
}stu[1001];
int cmp(inf x,inf y){
return x.tot>y.tot;
}
int main(){
scanf("%d",&n);
for (int i=1;i<=n;i++){
scanf("%s %d %d %d",&stu[i].name,&stu[i].Chi,&stu[i].mat,&stu[i].Eng);
stu[i].tot=stu[i].Chi+stu[i].mat+stu[i].Eng;
}
sort(stu+1,stu+1+n,cmp);
printf("%s %d %d %d",stu[1].name,stu[1].Chi,stu[1].mat,stu[1].Eng);
return 0;
}
orz
by fzj2007 @ 2020-07-01 15:30:29
@william_20080118 如果有多个总分相同的学生,输出靠前的那位。
orz被您吃了…
by william_20080118 @ 2020-07-01 15:49:28
@fzj2007 Thank you
by william_20080118 @ 2020-07-01 15:53:11
@fzj2007 但好像不是这的问题
by william_20080118 @ 2020-07-01 15:53:30
我是从1开始的
by fzj2007 @ 2020-07-01 16:28:46
@william_20080118 大哥sort排序油给你改的可能
by fzj2007 @ 2020-07-01 16:29:18
@william_20080118 加上一个number,然后在cmp里改一下
by fzj2007 @ 2020-07-01 16:29:36
@william_20080118 您这不是过了吗