C语言

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

clb736748749 @ 2022-12-02 22:31:48


struct
{
    char name[9];
    int CH, MT, EN, sum;
}str[1010];
int main()
{
    int N,max=0,j=0;
    scanf("%d", &N);
    struct str;
    for (int i = 0; i < N; i++)
    {
        scanf("%s",&str[i].name);
        scanf("%d", &str[i].CH);
        scanf("%d", &str[i].MT);
        scanf("%d", &str[i].EN);
        str[i].sum = str[i].CH + str[i].MT + str[i].EN;
        if (str[i].sum > max)
        {
            max = str[i].sum;
            j = i;
        }
    }
    printf("%s %d %d %d", str[j].name, str[j].CH, str[j].MT, str[j].EN);

    return 0;
}```

by 0123asd @ 2022-12-16 21:29:44

struct str;为什么?


|