翻看了一下,都是小错误
- 第16行,max应该等于0,而不是等于=st[0].sum,因为你是从下标0开始
- 第17行,同样的问题,改为1就好了
#### 修改代码(以ac)
```cpp
#include <stdio.h>
struct student{
char name[9];
int chinese,math,english,sum;
};
int main()
{
struct student st[1000];
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%s %d %d %d", st[i].name, &st[i].chinese, &st[i].math, &st[i].english);
st[i].sum=st[i].chinese+st[i].math+st[i].english;
}
int max=0,index;
for(int i=0;i<n;i++){
if(st[i].sum>max) { max=st[i].sum;index=i;}
}
printf("%s %d %d %d", st[index].name, st[index].chinese, st[index].math, st[index].english);
return 0;
}
```
by Baiwhiter @ 2020-12-11 19:14:05
希望更展现的Markdown?使用丰富。
by CGDGAD @ 2020-12-11 19:15:06
@[Baiwhiter](/user/127169) 好的谢谢大佬
by cjl2580 @ 2020-12-11 20:32:42
```cpp
#include <iostream>
using namespace std;
int n, maxi, maxV;
struct node {
int a, b, c;
char s[10];
}f[1005];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> f[i].s >> f[i].a >> f[i].b >> f[i].c;
int tmp = f[i].a + f[i].b + f[i].c;
if (tmp > maxV) maxV = tmp, maxi = i;
}
cout << f[maxi].s << " " << f[maxi].a << " " << f[maxi].b << " " << f[maxi].c << endl;
return 0;
}
```
by Tianxn @ 2021-01-09 20:59:13