1 条题解
-
0
#include <bits/stdc++.h>
using namespace std;
int main() { int n; int a[105];
int s1 = 0, s2 = 0, s3 = 0, s4 = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int j = 0; j < n; j++) { if (a[j] >= 0 && a[j] <= 18) { s1++; } else if (a[j] >= 19 && a[j] <= 35) { s2++; } else if (a[j] >= 36 && a[j] <= 60) { s3++; } else if (a[j] >= 61) { s4++; } } cout << fixed << setprecision(2); cout << 1.0 * s1 / n * 100 << "%" << endl; cout << 1.0 * s2 / n * 100 << "%" << endl; cout << 1.0 * s3 / n * 100 << "%" << endl; cout << 1.0 * s4 / n * 100 << "%" << endl; return 0;}
- 1
信息
- ID
- 12051
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 1
- 标签
- 递交数
- 28
- 已通过
- 15
- 上传者