Run ID:75405
提交时间:2024-05-26 17:28:29
#include<iomanip> #include<iostream> using namespace std; int main(){ int n; double q1,q2,q3,q4; q1 = q2 = q3 = q4 = 0.0; cin>>n; int a[10000]; for(int i=0;i<n;i++){ cin>>a[i]; } for(int i=0;i<n;i++){ if(a[i] >= 0 && a[i] <= 18){ q1++; }else if(a[i] >= 19 && a[i] <= 35){ q2++; }else if(a[i] >= 36 && a[i] <= 60){ q3++; }else { q4++; } } cout<<fixed<<setprecision(2)<<q1/n*100<<"%"<<endl; cout<<fixed<<setprecision(2)<<q2/n*100<<"%"<<endl; cout<<fixed<<setprecision(2)<<q3/n*100<<"%"<<endl; cout<<fixed<<setprecision(2)<<q4/n*100<<"%"<<endl; }