Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
31591 | 惠子铭 | 年龄与疾病 | C++ | Accepted | 0 MS | 260 KB | 495 | 2023-11-19 18:40:10 |
#include<iostream> #include<iomanip> #include<cstdio> using namespace std; const int N=1e4; int a[N]; int main() { int n; cin>>n; for(int i=1; i<=n; i++){ int age; cin>>age; if(age<=18) a[1]++; else if(age<=35) a[2]++; else if(age<=60) a[3]++; else a[4]++; } for(int i=1; i<=4; i++){ cout<<fixed<<setprecision(2)<<100.0*a[i]/n<<"%"<<endl; // printf("%.2lf%\n", 100.0*a[i]/n); } return 0; }