首页 > 代码库 > 求平均成绩(hdu2023)
求平均成绩(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)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。