| ||||||||||
| 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 | |||||||||
Re:这个printf("%.3lf%%\n", (double)count*100/n)就不能过了 但是printf("%.3f%%\n", (float)count*100/n)可以过In Reply To:Re:这个也可以过 Posted by:ElaxChin at 2011-08-07 16:29:34 #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 > 0.000001) {
count++;
}
}
printf("%.3lf%%\n", (double)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