Above Average


SUBMITTED BY: Guest

DATE: Dec. 5, 2013, 3:18 p.m.

FORMAT: C++

SIZE: 577 Bytes

HITS: 853

  1. #include<stdio.h>
  2. int main()
  3. {
  4. int kase,n,i;
  5. float avg, res,sum,cnt;
  6. float arr[1005];
  7. scanf("%d", &kase);
  8. char c = '%';
  9. while(kase--)
  10. {
  11. avg = 0;
  12. sum = 0;
  13. cnt = 0;
  14. scanf("%d", &n);
  15. for(i=0; i<n; i++) scanf("%f", &arr[i]);
  16. for(i=0; i<n; i++) sum = sum + arr[i];
  17. avg = (sum / n);
  18. for(i=0; i<n; i++) if(arr[i]>avg) cnt++;
  19. res = ((cnt/n)*100);
  20. printf("%.3f%c\n", res, c);
  21. }
  22. return 0;
  23. }

comments powered by Disqus