/*
Average score
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 62086 accepted submission (s): 14888
Problem description
Assume that there are n (n <= 50) students in a class, and each student takes an M (M <= 5) course. Calculate the average score of each student and the average score of each course, and the number of students whose scores are greater than or equal to the average score.
Input
The input data has multiple test instances. The first row of each test instance contains two integers, N and M, indicating the number of students and the number of courses, respectively. Then there are n rows of data, each row contains M integers (I .e., exam scores ).
Output
For each test instance, three rows of data are output. The first row contains N pieces of data, indicating the average score of N students. The result retains two decimals. The second row contains M pieces of data, indicates the average score of the M course, and the result is retained with two decimal places. The third row is an integer, indicating that the scores of all subjects in the class are greater than or equal to the average number of students.
Each test instance is followed by a blank line.
Sample Input
2 2
5 10
10 20
Sample output
7.50 15.00
7.50 15.00
1
*/
# Include <stdio. h>
# Include <string. h>
Int main ()
{
Int A [55] [10];
Double B [55], C [10]; // note type
Int I, j, n, m, K, T;
Double P, Q;
While (~ Scanf ("% d", & N, & M) //! = EOF end, cannot use while (scanf ("% d", & N, & M), N + M) questions do not have clear requirements, the default is EOF
{
Memset (B, 0, sizeof (B ));
Memset (C, 0, sizeof (c ));
For (I = 0; I <n; I ++)
{
P = 0;
For (j = 0; j <m; j ++)
{
Scanf ("% d", & A [I] [J]);
P + = A [I] [J];
}
B [I] = P/M;
}
For (j = 0; j <m; j ++)
{
Q = 0;
For (I = 0; I <n; I ++)
{
Q + = A [I] [J];
}
C [J] = Q/N;
}
T = 0;
For (I = 0; I <n; I ++)
{
K = 1;
For (j = 0; j <m; j ++)
{
If (A [I] [J] <C [J])
{
K = 0;
Break;
}
}
If (k) T ++;
}
For (I = 0; I <n-1; I ++)
{
Printf ("%. 2lf", B [I]);
}
Printf ("%. 2lf \ n", B [n-1]);
For (j = 0; j <m-1; j ++)
{
Printf ("%. 2lf", C [J]);
}
Printf ("%. 2lf \ n", M-1]);
Printf ("% d \ n", T); // do not forget: The last sentence of the question-each test instance is followed by a blank line
}
Return 0;
}
What I think:
Solution: Define three Arrays for addition and multiplication
Difficulties: Pay attention to the two outputs of a number component in the output format. Note that the. 2lf and K locations exist. Discuss often contains incomplete code.
Keywords: EOF. 2lf
Problem solving person: Yang shengsheng
Problem solving time: 2014.8.5
Problem-solving experience: Discuss had a pitfall and EOF