The 11th Blue Bridge Cup-Score Analysis

Topic description
Xiaolan organized an exam for the students. The total score is 100 points, and each student's score is an integer from 0 to 100.

Please calculate the highest score, lowest score and average score for this exam.

Input format
The first line of input contains an integer n, which represents the number of people in the exam.
In the next n rows, each row contains an integer from 0 to 100, representing a student's score.

Output format The
first line contains an integer, which represents the highest score.
The second line contains an integer that represents the lowest score.
The third line contains a real number, rounded to the nearest two decimal places, indicating an average score.

Input example
7
80
92
56
74
88
99
10

Sample output
99
10
71.29

Data range
For 50% of the evaluation cases, 1 ≤ n ≤ 100 1 ≤ n ≤ 1001n1 0 0
For all evaluation cases,1 ≤ n ≤ 10000 1 ≤ n ≤ 100001n10000


Problem solution
simulation:

#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    
    
    int n;
    cin >> n;
    
    int maxv = 0, minv = 100, sum = 0;
    for (int i = 0; i < n; i ++)
    {
    
    
        int x;
        cin >> x;
        minv = min(minv, x);
        maxv = max(maxv, x);
        sum += x;
    }
    
    cout << maxv << endl;
    cout << minv << endl;
    printf("%.2f", 1.0 * sum / n);
    return 0;
}

Lanqiao Cup C/C++ Group Provincial Competition Past Years Questions

Guess you like

Origin blog.csdn.net/weixin_46239370/article/details/115293016