Problem Description
Problem Analysis
A problem that trips you up on output formatting
I feel like the most meaningless kind of error is PE…
In the end, I kept changing things
and finally got AC
The idea is to output in three separate lines
using three sets of loops
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
| #include<stdio.h>
int main() {
int n,m;
while(scanf("%d %d",&n,&m)!=EOF) {
int a[55][10];
for(int i=0; i<n; i++)
for(int j=0; j<m; j++)
scanf("%d",&a[i][j]);
for(int i=0; i<n; i++) {
double sum=0;
for(int j=0; j<m; j++) {
sum+=a[i][j];
}
if(!i)
printf("%.2lf",sum/m);
else
printf(" %.2lf",sum/m);
}
printf("\n");
double x[10];
int cnt=0;
for(int i=0; i<m; i++) {
double sum=0;
for(int j=0; j<n; j++) {
sum+=a[j][i];
}
x[++cnt]=sum/n;
if(!i)
printf("%.2lf",x[cnt]);
else
printf(" %.2lf",x[cnt]);
}
printf("\n");
int k=0;
for(int i=0; i<n; i++) {
int j;
for(j=0; j<m; j++) {
if(a[i][j]<x[j+1]) {
break;
}
}
if(j>=m)
k++;
}
printf("%d\n\n",k);
}
return 0;
}
|
Problem link: 【HDU】[2023]Find the Average Score