求平均成绩(hdu2023)
Posted Strugglinggirl
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了求平均成绩(hdu2023)相关的知识,希望对你有一定的参考价值。
注意:要心细,不要错在小细节上。如int c[6];double agve; c[j]=agve;这是错误的。
#include<stdio.h> #include<cmath> int a[51][6]; double c[6]; int main() { int n; int m; char d; while (scanf_s("%d%d%c", &n, &m, &d) != EOF) { for (int i = 0; i<n; i++) { for (int j = 0; j<m; j++) { int b; scanf_s("%d", &b); a[i][j] = b; } } for (int i = 0; i<n; i++) { double sum = 0; double avge; for (int j = 0; j<m; j++) { sum = sum + a[i][j]; } avge = sum*1.0 / m; printf("%0.2lf", avge); if (i<n - 1) printf(" "); } printf("\\n"); for (int j = 0; j<m; j++) { double sum = 0; double avge; for (int i = 0; i<n; i++) { sum = sum + a[i][j]; } avge = sum*1.0 / n; c[j] = avge; printf("%0.2lf", avge); if (j<m - 1) printf(" "); } printf("\\n"); int count = 0; for (int i = 0; i<n; i++) { int count1 = 0; for (int j = 0; j<m; j++) { if (a[i][j] >= c[j]) count1++; } if (count1 == m) count++; } printf("%d\\n\\n", count); } }
以上是关于求平均成绩(hdu2023)的主要内容,如果未能解决你的问题,请参考以下文章