AcWing 2871. 成绩统计
原题链接
简单
C++ 代码
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int sixty;
int eight;
int sum;
int round(double n){
return (double)n*100+0.5;
}
int main() {
int n,temp;
cin>>n;
for(int i=0;i<n;++i){
scanf("%d",&temp);
sum++;
if(temp>=60){
sixty++;
if(temp>=85)
eight++;
}
}
double result1 =(double) eight/sum;
double result2 =(double) sixty/sum;
cout<<round(result2)<<'%'<<endl;
cout<<round(result1)<<'%'<<endl;
//cout<<eight*100/sum<<'%'<<endl;
return 0;
}