90分求助,C语言,求大佬看看

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

tjx1127 @ 2023-02-07 15:36:38

第八个点RE

#include<stdio.h>
int n,x,max,sum[500];
struct stu
{
    char name[9];
    int chinese,math,english;
};
int main()
{
    scanf("%d",&n);
    struct stu a[1000];
    for(int i=0;i<n;i++)
    {
        scanf("%s %d %d %d",&a[i].name,&a[i].chinese,&a[i].math,&a[i].english);
        sum[i]=a[i].chinese+a[i].math+a[i].english;
        if(max<sum[i]){max=sum[i];x=i;}
    }
    printf("%s %d %d %d ",a[x].name,a[x].chinese,a[x].math,a[x].english);
    return 0;
}

致谢!


by ud2_ @ 2023-02-07 15:40:24

N ≤ 1000,但 sumint[500]


by tjx1127 @ 2023-02-07 16:21:15

@ud2_ AC了,谢谢orz!


|