杭电2023 求平均成绩

C

#include <stdio.h>

int main()
{
    int n, m;
    while (scanf("%d %d", &n, &m) != EOF) {
        double s[n][m];
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m; ++j) {
                scanf("%lf", &s[i][j]);
            }
        }
        for (int i = 0; i < n; ++i) {
            double sum = 0;
            for (int j = 0; j < m; ++j) {
                sum += s[i][j];
            }
            if (!i) printf("%.2lf", sum / m);
            else printf(" %.2lf", sum / m);
        }
        printf("\n");
        double e[m];
        for (int i = 0; i < m; ++i) {
            double sum = 0;
            for (int j = 0; j < n; ++j) {
                sum += s[j][i];
            }
            e[i] = sum / n;
            if (!i) printf("%.2lf", e[i]);
            else printf(" %.2lf", e[i]);
        }
        printf("\n");
        int people = 0;
        for (int i = 0; i < n; ++i) {
            int flag = 1;
            for (int j = 0; j < m; ++j) {
                if (s[i][j] < e[j]) flag = 0;
            }
            if (flag) people += 1;
        }
        printf("%d\n\n", people);
    }
    return 0;
}
上一篇:300hero 模型提取教程(附2022模型下载)


下一篇:Vue 虚拟DOM和diff算法