提交时间:2024-10-27 10:04:03
运行 ID: 54314
#include<bits/stdc++.h> using namespace std; int main(){ double n, first_period = 0, second_period = 0, third_period = 0, fourth_period = 0; cin >> n; for(int i = 1; i <= n; i++){ int a; cin >> a; if(a <= 18){ first_period++; }else if(a <= 35){ second_period++; }else if(a <= 60){ third_period++; }else{ fourth_period++; } } double persent = first_period/n*100; cout << fixed << setprecision(2) << persent << "%" << endl; persent = second_period/n*100; cout << fixed << setprecision(2) << persent << "%" << endl; persent = third_period/n*100; cout << fixed << setprecision(2) << persent << "%" << endl; persent = fourth_period/n*100; cout << fixed << setprecision(2) << persent << "%" << endl; return 0; }