Hdu 2023 simple Java water too ~ ~ ~

Source: Internet
Author: User

Problem description assumes that there are N (n<=50) students in a class, each taking M (m<=5) courses, asking for the average score of each student and the average score of each course, and outputting the number of students who have been more than equal to the average score in each section.

Input data has multiple test instances, and the first line of each test instance consists of two integers n and m, each representing the number of students and the number of courses. Then there are n rows of data, each of which consists of m integers (that is, test scores).

Output for each test instance, outputs 3 rows of data, the first row contains n data, representing the average grade of n students, and the result retains two decimal places; the second row contains m data, which indicates the average score of M course, and the result retains two decimal places. The third line is an integer, Indicates the number of students in each section of the class who are above or equal to the average grade.

Each test instance is followed by a blank line.

Import java.util.*;import java.lang.*;class main{public static void Main (String args[]) {Scanner sc = new Scanner (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 the array */for (j=0;j<m;j++) {arr[i][j]=sc.nextint ();  }} int Sum;     for (i=0;i<n;i++) {/* Find average scores per 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++) {/* Average score for haunted Gate 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 who have not scored more 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 student's average score */if (nn==0) {System.out.printf ("%.2           F ", Arr1[j]);        nn++;        }else{System.out.printf ("%.2f", Arr1[j]);     }} System.out.println ();     nn=0; for (j=0;j<m;j++) {/* Output average scores per 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 newline */}}}

Hdu 2023 simple Java water too ~ ~ ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.