1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #include <iostream> using namespace std; int main() { int c, n, num; int avg; int score[1000] = {0}; double result; cin >> c; for (int i = 0; i < c; i++) { avg = 0; num = 0; cin >> n; for (int j = 0; j < n; j++) { cin >> score[j]; avg = avg + score[j]; } avg = avg / n; for (int j = 0; j < n; j++) { if (score[j] > avg) num++; } result = (double)num / n * 100; cout << fixed; cout.precision(3); cout << result << “%” << endl; } return 0; } | cs |