提交时间:2019-12-13 23:46:22
运行 ID: 3140
#include <iostream> #include <iomanip> using namespace std; int main() { int n, age, a[4]={0}; cin >> n; for (int i=0; i<n; i++){ cin >> age; if (age <= 18) a[0]++; else if (age>18 && age<36) a[1]++; else if (age>35 && age<61) a[2]++; else a[3]++; } for (int i=0; i<4; i++){ cout << fixed << setprecision(2) << (double)a[i]/n*100 << "%" << endl; } return 0; }