``` cpp
for(int i=0;i>n;i++)
{
if(sum[i]==maxx) cout<<q[i].name<<q[i].chi<<q[i].mat<<q[i].eng;
}
```
改为
``` cpp
for(int i=0;i<n;i++)
{
if(sum[i]==maxx) cout<<q[i].name<<q[i].chi<<q[i].mat<<q[i].eng;
}
```
by ZZQF5677 @ 2023-05-21 13:50:05
@[1125__qwq](/user/719208)
by ZZQF5677 @ 2023-05-21 13:50:20
`for(int i=0;i>n;i++)`
应改成
`for(int i=0;i<n;i++)`
by 2huk @ 2023-05-21 13:50:21
改了,还是无输出
```cpp
#include<bits/stdc++.h>
using namespace std;
int sum[1001];
int maxx;
struct student{
string name;
int eng;
int chi;
int mat;
}q[1001];
int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>q[i].name>>q[i].chi>>q[i].mat>>q[i].eng;
sum[i]=q[i].chi+q[i].eng+q[i].mat;
max(maxx,sum[i]);
}
for(int i=0;i<n;i++)
{
if(sum[i]==maxx) cout<<q[i].name<<q[i].chi<<q[i].mat<<q[i].eng;
}
return 0;
}
```
by ResonCaolol @ 2023-05-21 13:54:48
# 在代码中,max(maxx,sum[i])应该改为maxx=max(maxx,sum[i]),否则maxx的值不会更新为最大值。同时,在输出学生信息时,应该添加空格或换行符,否则输出的信息会连在一起。
## 修改后的代码如下:
```cpp
#include<点个关注吧>
using namespace std;
int sum[关注吧];
int maxx;
struct student{
string name;
int eng;
int chi;
int mat;
}q[1001];
int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>q[i].name>>q[i].chi>>q[i].mat>>q[i].eng;
sum[i]=q[i].chi+q[i].eng+q[i].mat;
maxx=max(maxx,sum[i]);
}
for(int i=0;i<n;i++)
{
if(sum[i]==maxx) cout<<q[i].name<<" "<<q[i].chi<<" "<<q[i].mat<<" "<<q[i].eng<<endl;
}
return 0;
}
```
by mcr123456 @ 2023-05-21 14:22:37
@[1125__qwq](/user/719208)
ok了。
```cpp
#include<bits/stdc++.h>
using namespace std;
int sum[1001];
int maxx;
struct student{
string name;
int eng;
int chi;
int mat;
}q[1001];
int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>q[i].name>>q[i].chi>>q[i].mat>>q[i].eng;
sum[i]=q[i].chi+q[i].eng+q[i].mat;
maxx=max(maxx,sum[i]);
}
for(int i=0;i<n;i++)
{
if(sum[i]==maxx) cout<<q[i].name<< " " << q[i].chi<< " "<<q[i].mat<< " "<<q[i].eng<<"\n";
}
return 0;
}
```
by ZZQF5677 @ 2023-05-21 14:24:09