The 11th Blue Bridge Cup-Results Statistics

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.

  • If the score is at least 60 points, it is called a pass.
  • If the score is at least 85 points, it is called excellent.

Please calculate the passing rate and the excellent rate, expressed as a percentage, and the part before the percentage sign is rounded to the nearest whole number.

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
Output two lines, each line with a percentage, respectively representing the passing rate and the excellent rate.

The part before the percent sign is rounded to the nearest whole number.

Input example
7
80
92
56
74
88
100
0

Sample output
71%
43%

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 <cmath>
using namespace std;

int main()
{
    
    
    int n;
    cin >> n;
    
    int a = 0, b = 0;
    for (int i = 0; i < n; i ++)
    {
    
    
        int x;
        cin >> x;
        if(x >= 60) a ++;
        if(x >= 85) b ++;
    }
    
    cout << round(100.0 * a / n) << '%' << endl;
    cout << round(100.0 * b / n) << '%' << endl;
    return 0;
}

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

Guess you like

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