你好,我看见你在知道上给人解答杭电2023题,也想请教你下,麻烦你了,谢谢
1个回答
展开全部
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
int n, m, i, j, flag, num;
double a[60][10], b[60], c[10];
while (~scanf("%d %d", &n, &m)) {
memset(a, 0, sizeof(a));
memset(b, 0, sizeof(b));
memset(c, 0, sizeof(c));
num = 0;
for (i = 1; i <= n; i++) {
for (j = 1; j <= m; j++) {
scanf("%lf", &a[i][j]);
b[i] += a[i][j];
}
c[1] += a[i][1];
c[2] += a[i][2];
c[3] += a[i][3];
c[4] += a[i][4];
c[5] += a[i][5];
}
b[1] /= m;
printf("%.2f", b[1]);
// 下面的 i 应该算到 n 而不是 m
for (i = 2; i <= n; i++) {
b[i] /= m;
printf(" %.2f", b[i]);
}
printf("\n");
c[1] /= n;
printf("%.2f", c[1]);
for (j = 2; j <= m; j++) {
c[j] /= n;
printf(" %.2f", c[j]);
}
printf("\n");
for (i = 1; i <= n; i++) {
flag = 1;
for (j = 1; j <= m; j++) {
if (a[i][j] < c[j]) {
flag = 0;
break;
}
}
num += flag;
}
printf("%d\n\n", num);
}
}
#include <stdlib.h>
#include <string.h>
int main() {
int n, m, i, j, flag, num;
double a[60][10], b[60], c[10];
while (~scanf("%d %d", &n, &m)) {
memset(a, 0, sizeof(a));
memset(b, 0, sizeof(b));
memset(c, 0, sizeof(c));
num = 0;
for (i = 1; i <= n; i++) {
for (j = 1; j <= m; j++) {
scanf("%lf", &a[i][j]);
b[i] += a[i][j];
}
c[1] += a[i][1];
c[2] += a[i][2];
c[3] += a[i][3];
c[4] += a[i][4];
c[5] += a[i][5];
}
b[1] /= m;
printf("%.2f", b[1]);
// 下面的 i 应该算到 n 而不是 m
for (i = 2; i <= n; i++) {
b[i] /= m;
printf(" %.2f", b[i]);
}
printf("\n");
c[1] /= n;
printf("%.2f", c[1]);
for (j = 2; j <= m; j++) {
c[j] /= n;
printf(" %.2f", c[j]);
}
printf("\n");
for (i = 1; i <= n; i++) {
flag = 1;
for (j = 1; j <= m; j++) {
if (a[i][j] < c[j]) {
flag = 0;
break;
}
}
num += flag;
}
printf("%d\n\n", num);
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询