UVa 10370 – Above Average


/*
User ID: turing_13
Link: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1311
*/

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,c,ara[1000],i,j=0;
    float ans,avarage=0;
    scanf("%d", &n);
    while(n--)
    {
        scanf("%d", &c);
        for(i=0;i<c;i++)
        {
            scanf("%d", &ara[i]);
            avarage+=(float)(ara[i]);
        }
        avarage/=c;
        for(i=0;i<c;i++)
        {
            if(ara[i]>avarage)
                j++;
        }
        ans=(float)j/c*100;
        printf("%.3lf%%\n",ans);
        avarage=j=0;
    }
    return 0;
}


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s