有dl可以看一下吗?
查看原帖
有dl可以看一下吗?
593001
Langrange2021楼主2022/9/17 17:43
#include <stdio.h>
#include <string.h>
struct test
{
    char name[9];
    int chin;
    int math;
    int eng;
};
int main()
{
    int max = -1;
    int N;
    scanf("%d", &N);
    char na[9];
    int ch = 0;
    int ma = 0;
    int en = 0;
    for (int k = 0; k < N; k++)
    {
        struct test store;
        int sum;
        scanf("%s", store.name);
        scanf("%d%d%d", &store.chin, &store.math, &store.eng);
        sum = store.chin + store.math + store.eng;
        if (sum > max)
        {
            max = sum;
            for (int q = 0; q < 9; q++)
            {
                if (store.name[q] == '\0')
                {
                    break;
                }
                na[q] = store.name[q];
            }
            ch = store.chin;
            ma = store.math;
            en = store.eng;
        }
    }
    for (int y = 0; y < 9; y++)
    {
        if (na[y] == '\0')
        {
            break;
        }
        printf("%c", na[y]);
    }
    printf(" ");
    printf("%d %d %d", ch, ma, en);
    return 0;
}
2022/9/17 17:43
加载中...