Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
54303 | zhangsicun | 年龄与疾病 | C++ | 通过 | 0 MS | 248 KB | 870 | 2024-10-27 09:42:16 |
#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; }