啥问题捏

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

Eletronic_Monkey @ 2024-10-21 13:28:43

#include<stdio.h>
int main()
{
    int n,temp=0,max;
    struct student
    {
        char name[100];
        int a;
        int b;
        int c;
    };
        scanf("%d",&n);
        struct student student[n];
        int sum[n];
    for(int i=0;i<n;i++)
    {
        scanf("%s %d %d %d",&student[i].name,&student[i].a,&student[i].b,&student[i].c);
        sum[i]=student[i].a+student[i].b+student[i].c;
    }
        max=sum[0];
    for(int j=0;j<n;j++)
    {
        if(sum[j]>sum[0])
        {
            max=sum[j];
            temp=j;
        }
    }
    printf("%s %d %d %d",student[temp].name,student[temp].a,student[temp].b,student[temp].c);
    return 0;
}

|