闭月羞花指的是女孩子啊
by _短笛无腔_ @ 2021-03-28 20:49:20
@[wx310756](/user/468076) 输出写错了
改成这样
```cpp
cout<<a[0].name<<" "<<a[0].ch<<" "<<a[0].ma<<" "<<a[0].en;
```
by _短笛无腔_ @ 2021-03-28 20:50:52
谢谢各位大佬!
by Yunjin @ 2021-03-28 20:54:09
简单改了四五个细节
代码先贴在这 不懂的可以at我
```cpp
#include<iostream>
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<cmath>
using namespace std;
struct stu{
// changed a line here
char name[9];
int ch,ma,en;
// changed a line here
int all, num;
};
bool cmp(stu t1,stu t2){
// added two lines here
if (t1.all == t2.all)
return t1.num < t2.num;
return t1.all>t2.all;
}
int main(){
int shuliang = 0;
stu a[1005];
cin>>shuliang;
for(int i = 0;i < shuliang;i++){
cin>>a[i].name>>a[i].ch>>a[i].ma>>a[i].en;
// added a line here
a[i].num = i;
a[i].all = a[i].ch+a[i].ma+a[i].en;
}
sort(a,a+shuliang,cmp);
// changed a line here
cout<<a[0].name<<" "<<a[0].ch<<" "<<a[0].ma<<" "<<a[0].en << endl;
return 0;
}//谁可以帮我看看错在哪了/(T-T)\
```
by Maxmilite @ 2021-03-28 20:56:07
@[wx310756](/user/468076)
by Maxmilite @ 2021-03-28 20:56:15
谢谢大家!我过啦! @(^-^)@
by Yunjin @ 2021-03-28 20:59:54
@[wx310756](/user/468076) stable_sort()会更好一些
by ZBAA_MKC @ 2021-03-28 21:18:25