HDU 2023

来源:互联网 发布:网络推广访问者 编辑:程序博客网 时间:2024/04/25 12:57
#include<iostream>#include<iomanip>using namespace std;#define ROWS 55#define COLUMNS 10int main(){    int n, m, ans;    double grade[ROWS][COLUMNS];    double temp_r, temp_c;    bool judge;    while(cin >> n >> m)    {        ans = 0;        for(int i = 0; i < n; i++)        {            temp_r = 0.0;            for(int j = 0; j < m; j++)            {                cin >> grade[i][j];                temp_r += grade[i][j];            }            grade[i][m] = temp_r / m;        }        for(int i = 0; i < m; i++)        {            temp_c = 0.0;            for(int j = 0; j < n; j++)                temp_c += grade[j][i];            grade[n][i] = temp_c / n;        }        for(int i = 0; i < n; i++)        {            judge = true;            for(int j = 0; j < m; j++)                if(grade[i][j] < grade[n][j])                {                    judge = false;                    break;                }            if(judge)                ans++;        }        for(int i = 0; i < n; i++)        {            if(i != 0)                cout << ' ';            cout << fixed;            cout << setprecision(2) << grade[i][m];        }        cout << endl;        for(int i = 0; i < m; i++)        {            if(i != 0)                cout << ' ';            cout << fixed;            cout << setprecision(2) << grade[n][i];        }        cout << endl;        cout << ans << endl;        cout << endl;    }    return 0;}

0 0
原创粉丝点击