| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
这个题目有bug,double不能过,改成float了之后就过了#include <stdio.h>
#include <string.h>
#define N 1000
int main()
{
int t, n;
int A[N];
scanf("%d",&t);
while(t--) {
memset(A, 0.0, sizeof(A));
scanf("%d", &n);
int i = 0;
double sum = 0;
int num = n;
while(num--) {
scanf("%d",&A[i]);
sum += A[i];
i++;
}
double average = 0;
average = sum / n;
int count = 0;
for (i = 0; i < n; i++) {
if (A[i] > average) {
count++;
}
}
printf("%.3f%%\n", (float)count*100/n);
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator