Run ID:107000

提交时间: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; }