Hdu 2023 simple java ~~~, Hdu2023java
Problem Description assume that a class has n (n <= 50) students and each student takes m (m <= 5) courses, calculate the average score of each student and the average score of each course, and output the number of students whose scores are greater than or equal to the average score.
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 outputs three rows of data for each test instance. The first row contains n data, which indicates the average score of n students. The result retains two decimals. The second row contains m 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.
Import java. util. *; import java. lang. *; class Main {public static void main (String args []) {program SC = new program (System. in); while (SC. hasNext () {int n = SC. nextInt (); int m = SC. nextInt (); double [] [] arr = new double [n] [m]; double [] arr1 = new double [n]; double [] arr2 = new double [m]; int count, k = 0, I, j; for (I = 0; I <n; I ++) {/* load the input score into an array */for (j = 0; j <m; j ++) {arr [I] [j] = SC. nextInt () ;}} int Sum; for (I = 0; I <n; I ++) {/* calculate the average score of each person */Sum = 0; for (j = 0; j <m; j ++) {Sum + = arr [I] [j];} arr1 [I] = 1.0 * Sum/m ;} for (I = 0; I <m; I ++) {/* obtain the average score of a course that does not have a course */Sum = 0; for (j = 0; j <n; j ++) {Sum + = arr [j] [I];} arr2 [I] = 1.0 * Sum/n;} count = 0; for (I = 0; I <n; I ++) {/* count the number of students whose scores are greater than the average score */k = 0; for (j = 0; j <m; j ++) {if (arr [I] [j]> = arr2 [j]) {k ++ ;}} if (k = m) {count ++ ;}} int nn = 0; for (j = 0; j <n; j ++) {/* output the average score of the student */if (nn = 0) {System. out. printf ("%. 2f ", arr1 [j]); nn ++;} else {System. out. printf ("%. 2f ", arr1 [j]) ;}} System. out. println (); nn = 0; for (j = 0; j <m; j ++) {/* output the average score of each course */if (nn = 0) {System. out. printf ("%. 2f ", arr2 [j]); nn ++;} else {System. out. printf ("%. 2f ", arr2 [j]) ;}} System. out. println (); System. out. println (count); System. out. println ();/* last line feed */}}}