Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
75405 刘津希 18患病人数占总患病人数的比例 C++ Accepted 1 MS 280 KB 625 2024-05-26 17:28:29

Tests(10/10):


Code:

#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; }