Thursday, January 28, 2016

UVA 10370 | | Above Average

#include<stdio.h>
int main()
{
  float total=0,count=0,a[1001],avrg=0,stdnt=0;
  int i , t;
  scanf("%d",&t);
  while(t--){
    scanf("%f",&stdnt);
    for(i=0; i<stdnt; i++){
        scanf("%f",&a[i]);
        total+=a[i];
    }
    avrg=total/stdnt;
    for(i=0; i<stdnt; i++){
        if(a[i]>avrg)
            count++;
     }
     printf("%.3f%%\n",(count*100)/stdnt);
     total=0;
     count=0;
  }
    return 0;
}

No comments:

Post a Comment