题目描述
成绩统计 - 蓝桥云课 (lanqiao.cn)
题目分析
学会使用四舍五入函数round
#include<bits/stdc++.h>
using namespace std;
int s1, s2;
int main()
{
int n, x;
cin >> n;
for(int i = 1; i <= n; i ++)
{
cin >> x;
if(x >= 60)s1 ++;
if(x >= 85)s2 ++;
}
double ss1 = s1 * 1.0 / n;
double ss2 = s2 * 1.0 / n;
ss1 *= 100;
ss2 *= 100;
cout << round(ss1) << "%" << '\n';
cout << round(ss2) << "%" << '\n';
return 0;
}