通过代码:
#include <bits/stdc++.h> using namespace std; int n, a, _18, _35, _60, _top; int main() { scanf("%d", &n); for(int i = 1; i <= n; i ++) { scanf("%d", &a); if(a <= 18) _18 ++; else if(a <= 35) _35 ++; else if(a <= 60) _60 ++; else _top ++; } printf("%.2lf%c\n", 100 * (double)_18 / (double)n, '%'); printf("%.2lf%c\n", 100 * (double)_35 / (double)n, '%'); printf("%.2lf%c\n", 100 * (double)_60 / (double)n, '%'); printf("%.2lf%c", 100 * (double)_top / (double)n, '%'); return 0; }
1106:年龄与疾病
最新推荐文章于 2024-01-22 09:54:52 发布