Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
127871 陈淮遇 18患病人数占总患病人数的比例 C++ Accepted 1 MS 268 KB 660 2025-07-29 17:30:24

Tests(10/10):


Code:

#include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } int c = 0; int d = 0; int e = 0; int f = 0; for (int j = 0; j < n; j++) { if ( a[j] <= 18 ) { c++; } if (a[j] >= 19 && a[j] <= 35 ) { d++; } if (a[j] >= 36 && a[j] <= 60 ) { e++; } if (a[j] >= 61 ) { f++; } } printf("%.2f", c * 100.0 / n); cout << "%"; cout << endl; printf("%.2f", d * 100.0 / n); cout << "%"; cout << endl; printf("%.2f", e * 100.0 / n); cout << "%"; cout << endl; printf("%.2f", f * 100.0 / n); cout << "%"; return 0; }