家人们,求助啊

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

linyiyi123456 @ 2023-03-10 01:02:19

#include<stdio.h>
struct node{
    char name;
    int chinese;
    int math;
    int english;
    int all;
}student[1000];
int main()
{
    int n,i,max=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s %d %d %d",&student[i].name,&student[i].chinese,&student[i].math,&student[i].english);
        student[i].all=student[i].chinese+student[i].english+student[i].math;
        if(student[i].all>max)
        {
            max=student[i].all;
        }

    }
    for(i=0;i<n;i++)
    {
        if(student[i].all==max)
        {
            printf("%s %d %d %d",student[i].name,student[i].chinese,student[i].math,student[i].english);
            break;
        }
    }
    return 0;
}

by 2104300103xf @ 2023-03-10 10:24:30

name应该是个char数组,而不是一个字符


|