简单题。
thestoryofsnow | 2350 | Accepted | 164K | 0MS | C++ |
/*
ID: thestor1
LANG: C++
TASK: poj2305
*/
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <limits>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cassert>
using namespace std;
const int MAXN = 1000;
int main()
{
int C;
scanf("%d", &C);
int grades[MAXN];
for (int t = 0; t < C; ++t)
{
int N;
scanf("%d", &N);
for (int i = 0; i < N; ++i)
{
scanf("%d", &grades[i]);
}
double sum = 0.0;
for (int i = 0; i < N; ++i)
{
sum += grades[i];
}
double avg = sum / N;
int nabove = 0;
for (int i = 0; i < N; ++i)
{
if (grades[i] > avg)
{
nabove++;
}
}
printf("%.3lf%%\n", nabove * 100.0 / N);
}
return 0;
}