Next time post in the existing thread.
Only read the number of test cases once.
10370 - Above Average
Moderator: Board moderators
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10370 - Above Average
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 3
- Joined: Fri Jan 23, 2015 9:33 am
Re: 10370 - Above Average
why getting WA?
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;
}
Last edited by brianfry713 on Tue Jan 27, 2015 12:58 am, edited 1 time in total.
Reason: Added code blocks
Reason: Added code blocks
Re: 10370 - Above Average
Variable N is float, so change
to
Code: Select all
scanf("%d",&N);
Code: Select all
scanf("%f",&N);
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman