Run ID Author Problem Lang Verdict Time Memory Code Length Submit Time
54314 zhangweiran 年龄与疾病 C++ Accepted 1 MS 252 KB 870 2024-10-27 10:04:03

Tests(1/1):


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


Judgement Protocol: