救救孩子吧,样例过了,求大牛调

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

GMU___LXB @ 2024-11-18 19:58:46

#include<bits/stdc++.h>
using namespace std;
int main()
{
    struct xs
    {
        string mz;
        int num1;
        int num2;
        int num3;
        int sum;
    };
    int n;
    cin>>n;
    xs arr[1001];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i].mz>>arr[i].num1>>arr[i].num2>>arr[i].num3;
        arr[i].sum=arr[i].num1+arr[i].num2+arr[i].num3;
    }
    for(int i=0;i<n;i++)
    {
        if(arr[0].sum<arr[i].sum)
        {
            arr[0].mz=arr[i].mz;
            arr[0].num1=arr[i].num1;
            arr[0].num2=arr[i].num2;
            arr[0].num3=arr[i].num3;
        }
    }
    cout<<arr[0].mz<<" "<<arr[0].num1<<" "<<arr[0].num2<<" "<<arr[0].num3<<endl;
    return 0;
}

|