- chenxueze's blog
1106:年龄与疾病
- 2024-12-18 18:27:00 @
#include<bits/stdc++.h>
using namespace std;
int main () {
int n;
cin >> n;
int s;
int a[4] = {};
for (int i = 1;i <= n ; i++) {
cin >> s;
if (s >= 0 && s <= 18) {
a[0] ++;
}
else if (s >= 19 && s <= 35) {
a[1] ++;
}
else if (s >= 36 && s <= 60) {
a[2] ++;
}
else {
a[3] ++;
}
}
for (int i = 0; i < 4 ; ++i) {
cout << fixed << setprecision(2) <<(double)a[i] / n * 100 << "%" << endl;
}
return 0;
}