Problem ID - 10370,
Problem Name - Above Average
Problem Description is Here
#include<stdio.h>
main()
{
int test, n, i, stud[1000];
float sum, ave, count, percent;
char ch='%';
scanf("%d", &test);
while(test--)
{
sum=ave=count=percent=0;
scanf("%d", &n);
for(i=0;i<n;i++)
{
scanf("%d", &stud[i]);
sum+=stud[i];
}
ave=sum/(float)n;
for(i=0;i<n;i++)
{
if(stud[i]>ave)
{
count++;
}
}
percent=(count*100.0)/(float)n;
printf("%.3f%c\n", percent, ch);
}
return 0;
}
0 comments:
Post a Comment