HUD 2023 calculates the average

Source: Internet
Author: User
Average score

Time Limit: 2000/1000 MS (Java/others )???? Memory limit: 65536/32768 K (Java/Others)
Total submission (s): 61990 ???? Accepted submission (s): 14860


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 input2 2 5 10 10 20?

?

Sample output7.50 15.00 7.50 15.00 1?

?

Question:

# Include <iostream>

# Include <algorithm>

# Include <cmath>

# Include <string>

# Include <cstdio>

# Include <vector>

Usingnamespacestd;

Float datas [55] [5];

?

Int main (){

? ? Int n, m;

? ? While (scanf ("% d", & N, & M )! = EOF ){

? ? ? ? Vector <bool> item_mask (N );

? ? ? ? For (INT I = 0; I <n; I ++ ){

? ? ? ? ? ? Float sum = 0;

? ? ? ? ? ? For (Int J = 0; j <m; j ++ ){

? ? ? ? ? ? ? ? Scanf ("% F", & datas [I] [J]);

? ? ? ? ? ? ? ? Sum + = datas [I] [J];

? ? ? ? ? ? }

? ? ? ? ? ? If (I! = 0) printf ("");

? ? ? ? ? ? Printf ("%. 2f", sum/M );

? ? ? ? }

? ? ? ? Printf ("\ n ");

?? ? ? ?

? ? ? ? For (int K = 0; k <item_mask.size (); k ++) {// Initialization

? ? ? ? ? ? Item_mask [k] = true;

? ? ? ? }

? ? ? ? For (Int J = 0; j <m; j ++ ){

? ? ? ? ? ? Float sum = 0;

? ? ? ? ? ? For (INT I = 0; I <n; I ++)

? ? ? ? ? ? ? ? Sum + = datas [I] [J];

? ? ? ? ? ? If (J! = 0 )? Printf ("");

? ? ? ? ? ? Sum/= N;

? ? ? ? ? ? For (INT I = 0; I <n; I ++)

? ? ? ? ? ? ? ? If (datas [I] [J] <sum) // eliminate persons whose scores are lower than the average

? ? ? ? ? ? ? ? ? ? Item_mask [I] = false;

? ? ? ? ? ? Printf ("%. 2f", sum );

? ? ? ? }

? ? ? ? Printf ("\ n ");

? ? ? ? Int COUNT = 0;

? ? ? ? For (INT I = 0; I <n; I ++)

? ? ? ? ? ? Count + = item_mask [I];

? ? ? ? Printf ("% d \ n", count); // each test instance is followed by an empty line

? ? }

}

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.