qleizhengye2022 @ 2023-12-27 22:26:11
#include<bits/stdc++.h>
using namespace std;
int chinese,maths,English,maxn,ch1,ma1,En1,s1,n;
string s,s2;
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>s>>chinese>>maths>>English;
int s1=chinese+maths+English;
if(s1>maxn)
{
s2=s;
maxn=s1;
ch1=chinese;
ma1=maths;
En1=English;
}
}
cout<<s2<<" "<<ch1<<" "<<ma1<<" "<<En1;
return 0;
}
求助求助
by temp142857 @ 2023-12-27 22:50:52
maxn初始为0,如果所有人总分都为0,if括起来的内容就不会执行,可以把maxn置为-1,或者初始化答案为第一个人的数据
by qleizhengye2022 @ 2023-12-30 18:02:51
@temp142857 感谢,爱你