为啥re了

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

lucus_Fu0202 @ 2024-05-04 14:48:36

#include<bits/stdc++.h>
using namespace std;
struct node{
    string name;
    int mark1,mark2,mark3,marksum;
}a[6];
int main(){
    int n;
    cin>>n;
    for(int i = 1 ; i <= n ; i++){
        cin>>a[i].name>>a[i].mark1>>a[i].mark2>>a[i].mark3;
        a[i].marksum = a[i].mark1 + a[i].mark2 + a[i].mark3;
    }
    int mx = 1;
    for(int i = 2 ; i <= n ; i++){
        if(a[i].marksum > a[mx].marksum){
            mx = i;
        }
    }
    cout<<a[mx].name<<' '<<a[mx].mark1<<' '<<a[mx].mark2<<' '<<a[mx].mark3;
    return 0;
}

by liyixin0514 @ 2024-05-04 14:51:13

数组 a 要开到 1000 以上。


by lucus_Fu0202 @ 2024-05-04 15:13:26

谢谢,已经过了。


|