Re: 10370 - Above Average
Posted: Fri Jan 09, 2015 12:18 am
Next time post in the existing thread.
Only read the number of test cases once.
Only read the number of test cases once.
The Online Judge board
https://uva.onlinejudge.org/board/
https://uva.onlinejudge.org/board/viewtopic.php?f=20&t=27040
Code: Select all
#include<stdio.h>
int main()
{
int C,i,j,count;
int grade[1002];
float percentage,sum,avrg_grade,N;
scanf("%d",&C);
for(i=0;i<C;i++)
{
sum=0;
count=0;
avrg_grade=0;
scanf("%d",&N);
for(j=0;j<N;j++)
{
scanf("%d",&grade[j]);
}
for(j=0;j<N;j++)
{
sum=sum+grade[j];
}
avrg_grade=sum/N;
for(j=0;j<N;j++)
{
if(grade[j]>avrg_grade)
count++;
else
;
}
percentage=(100*count)/N;
printf("%.3f%%\n",percentage);
}
return 0;
}
Code: Select all
scanf("%d",&N);
Code: Select all
scanf("%f",&N);