Page 5 of 5

Re: 10370 - Above Average

Posted: Fri Jan 09, 2015 12:18 am
by brianfry713
Next time post in the existing thread.
Only read the number of test cases once.

Re: 10370 - Above Average

Posted: Sat Jan 24, 2015 10:04 am
by Sabrina Haque
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;

}

Re: 10370 - Above Average

Posted: Sat Jan 24, 2015 12:49 pm
by lighted
Variable N is float, so change

Code: Select all

scanf("%d",&N);
to

Code: Select all

scanf("%f",&N);