Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
107000 | 杜洛雨泽 | 18患病人数占总患病人数的比例 | C++ | Accepted | 1 MS | 268 KB | 743 | 2025-01-17 10:51:34 |
#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 x = 0, y = 0, z = 0, w = 0; for (int i = 0; i < n; i++) { if (a[i] >= 0 && a[i] <= 18) { x++; } if (a[i] >= 19 && a[i] <= 35) { y++; } if (a[i] >= 36 && a[i] <= 60) { z++; } if (a[i] >= 61) { w++; } } int d = x + y + z + w; double b = x * 1.00 / d * 100; double e = y * 1.00 / d * 100; double r = z * 1.00 / d * 100; double c = w * 1.00 / d * 100; printf("%.2f", b); cout << "%" << endl; printf("%.2f", e); cout << "%" << endl; printf("%.2f", r); cout << "%" << endl; printf("%.2f", c); cout << "%" << endl; return 0; }