标签:pre alt 错误 char 1.0 技术分享 ble #include std
注意:要心细,不要错在小细节上。如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); } }
标签:pre alt 错误 char 1.0 技术分享 ble #include std
原文地址:http://www.cnblogs.com/Strugglinggirl/p/5988950.html