HDU2023 average score

Source: Internet
Author: User

Original question: 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. Sample Input 2 25 1010 20 Sample Output 7.50 15.007.50 15.001 source code: [cpp] # include <stdio. h> # include <string. h> int main () {int n, m; int I, j; int t, d; int s [50]; int c [5]; int SC [50] [5]; while (scanf ("% d", & n, & m )! = EOF) {memset (s, 0, sizeof (s); memset (c, 0, sizeof (c); memset (SC, 0, sizeof (SC )); for (I = 0; I <n; I ++) {for (j = 0; j <m; j ++) {scanf ("% d ", & SC [I] [j]); c [j] + = SC [I] [j]; s [I] + = SC [I] [j];} for (I = 0; I <n; I ++) printf ("%. 2lf % c ", s [I] * 1.0/m, I <n-1? '': '\ N'); for (I = 0; I <m; I ++) printf (" %. 2lf % c ", c [I] * 1.0/n, I <m-1? '': '\ N'); for (t = I = 0; I <n; I ++) {for (d = 1, j = 0; j <m; j ++) {if (SC [I] [j] <1.0 * c [j]/n) {d = 0; break ;}} if (d) t ++;} printf ("% d \ n", t);} return 0 ;}

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.