zoukankan      html  css  js  c++  java
  • hdoj:2023

    #include <iostream>
    #include <string>
    #include <vector>
    double a[51][6],b[51],c[6];
    using namespace std;
    int main()
    {
        int n, m;
        
        int count = 0;
        while (cin >> n >> m)
        {    
            count = 0;
            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= m; j++)
                {
                    cin >> a[i][j];
                }
            }
            // 学生的平均成绩
            for (int i = 1; i <= n; i++)
            {
                double r = 0;
                for (int j = 1; j <= m; j++)
                {
                    r = r + a[i][j];
                }
                b[i] = r/m;
            }
            // 课程的平均值成绩
            for (int j = 1; j <= m; j++)
            {
                double col = 0;
                for (int i = 1; i <= n; i++)
                {
                    col = col + a[i][j] ;
                }
                c[j] = col/n;
            }
            // 统计学生成绩均大于课程平均成绩的数量
            for (int i = 1; i <= n; i++)
            {
                int k = 0;
                for (int j = 1; j <= m; j++)
                {
                    if (a[i][j] >= c[j])
                    {
                        k++;
                    }
                }
                if (k == m)
                {
                    count++;
                }
            }
            // 输出 
            for (int i = 1; i < n; i++)
                printf("%.2lf ", b[i]);
            printf("%.2lf
    ", b[n]);
            for (int j = 1; j < m; j++)
                printf("%.2lf ", c[j]);
            printf("%.2lf
    ", c[m]);
            printf("%d
    
    ", count);
        }
    }
  • 相关阅读:
    Programming Contest Ranking(题解)
    Alphabet Cookies
    hpu 1267 Cafeteria (01背包)
    Triangles 正多边形分割锐角三角形
    ACdream 1067:Triangles
    hdu 1253 胜利大逃亡 (代码详解)解题报告
    最短路
    POJ- 1511 Invitation Cards
    E
    HDU
  • 原文地址:https://www.cnblogs.com/bbbblog/p/5998342.html
Copyright © 2011-2022 走看看