求助,90分,样例三一直过不了

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

jkluio1 @ 2024-03-17 17:11:10

struct student {
    char name[8];
    int score[3];
    int sum=0;
};
int main()
{
    student s[1001];
    int n = 0,max=0,maxidex=0;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> s[i].name;
        for (int j = 0; j < 3; j++)
        {
            cin >> s[i].score[j];
            s[i].sum+= s[i].score[j];
        }
        if (s[i].sum > max)
        {
            max = s[i].sum;
            maxidex = i;
        }
    }
    cout << s[maxidex].name<<" ";
    for (int i = 0; i < 3; i++)
        cout << s[maxidex].score[i] << " ";
    return 0;
}

by hoty2011 @ 2024-03-21 17:54:43

把结构体里的name数组开大一点就AC了。


|