提交时间:2019-12-07 14:29:04

运行 ID: 2827

#include <stdio.h> int main() { int a[100], i; int n; double x018 = 0, x1935 = 0, x3660 = 0, x60 = 0; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &a[i]); } for (i = 0; i < n; i++) { if (a[i] <= 18) { x018++; } if (a[i] > 18 && a[i] <= 35) { x1935++; } if (a[i] >= 36 && a[i] <= 60) { x3660++; } if (a[i] > 60) { x60++; } } printf("1-18: %.2f%%\n19-35: %.2f%%\n36-60: %.2f%%\n60-: %.2f%%\n", x018 * 100.00 / n, x1935 * 100.00 / n, x3660 * 100.00 / n, x60 * 100.00 / n); getchar(); getchar(); return 0; }