1 条题解

  • 0
    @ 2026-11-3 22:49:53

    空 1

    c + m + e
    

    三科相加得到总分。

    空 2

    c + m
    

    语文与数学之和作为第二比较项。

    空 3

    c > m ? c : m;
    

    条件运算符取得语文与数学的最大值;相等时取任一个都正确。

    空 4

    1
    

    初始排名为1,每发现一名严格更优的同学就加1。

    空 5

    total[j] > total[i]
                    || (total[j] == total[i] && combined[j] > combined[i])
                    || (total[j] == total[i] && combined[j] == combined[i]
                        && highest[j] > highest[i])
    

    依次比较总分、语数和、语数最高分;严格大于才计入人数,三项全等时不计入。

    完整 C 程序

    #include <stdio.h>
    
    int total[10000], combined[10000], highest[10000];
    
    int main(void)
    {
        int n;
        scanf("%d", &n);
        for (int i = 0; i < n; ++i) {
            int c, m, e;
            scanf("%d%d%d", &c, &m, &e);
            total[i] = c + m + e;
            combined[i] = c + m;
            highest[i] = c > m ? c : m;
        }
        for (int i = 0; i < n; ++i) {
            int rank = 1;
            for (int j = 0; j < n; ++j) {
                if (total[j] > total[i]
                    || (total[j] == total[i] && combined[j] > combined[i])
                    || (total[j] == total[i] && combined[j] == combined[i]
                        && highest[j] > highest[i])) {
                    ++rank;
                }
            }
            printf("%d\n", rank);
        }
        return 0;
    }
    
    • 1

    信息

    ID
    643
    时间
    3000ms
    内存
    128MiB
    难度
    6
    标签
    递交数
    19
    已通过
    11
    上传者