90分,求助!!!!!!!!

P5740 【深基7.例9】最厉害的学生

mediocre_ @ 2022-03-04 07:09:01

#include<bits/stdc++.h>
using namespace std;
struct x{
    string name;
    int chinese,maths,English;
}a,ans;
int main(){
    int n;
    scanf("%d",&n);
    for (int i = 1;i <= n;++i){
        cin>>a.name>>a.chinese>>a.maths>>a.English;
        if (a.chinese+a.maths+a.English > ans.chinese+ans.maths+ans.English){
            ans = a;
        }
    }
    cout<<ans.name<<" "<<ans.chinese<<" "<<ans.maths<<" "<<ans.English;
    return 0;
}

by Nygglatho @ 2022-03-04 16:50:37

@Mr_Huang12 注意特判 N 名同学成绩均为 0 的情况,例如该数据。


|