Above Average

It is said that 90% of frosh expect to be above average in their class. You are to provide a reality check.

The first line of standard input contains an integer C, the number of test cases. C data sets follow. Each data set begins with an integer, N, the number of people in the class (1 <= N <= 1000). N integers follow,
separated by spaces or newlines, each giving the final grade (an integer between 0 and 100) of a student in the class. For each case you are to output a line giving the percentage of students whose grade is above average, rounded to 3 decimal places.

Sample Input

5
5 50 50 70 80 100
7 100 95 90 80 70 60 50
3 70 90 80
3 70 90 81
9 100 99 98 97 96 95 94 93 91

Output for Sample Input

40.000%
57.143%
33.333%
66.667%
55.556%

#include <stdio.h>
int arr[1002], id;
double ave; int main()
{
int t, n, i, count;
scanf("%d", &t);
while(t--){
scanf("%d", &n);
ave = 0;
for(i = 0; i < n; ++i){
scanf("%d", arr + i);
ave += arr[i];
}
ave /= n;
count = 0; for(i = 0; i < n; ++i)
if(arr[i] > ave) ++count;
printf("%.3lf%%\n", count * 100.0 / n);
}
return 0;
}

最新文章

  1. linux组、用户操作相关
  2. 关于HTTP session随笔
  3. ubuntu 13.04下MYSQL 5.5环境搭建
  4. AngularJs angular.identity和angular.noop
  5. centos yum 安装
  6. mysql 与 oracle 比较(一)group by 容易产生的误解
  7. DVRF:路由器漏洞练习靶机 Damn Vulnerable Router Firmware
  8. sql server 2008 执行计划
  9. Java基础知识强化之IO流笔记82:NIO之 Pipe(管道)
  10. zedboard U盘挂载+交叉编译helloworld
  11. uploadify控制 上传图片到百度云存储
  12. JAVA提高十一:LinkedList深入分析
  13. js中select标签中的option选择
  14. 「Python」6种python中执行shell命令方法
  15. ASP.NET Core ResponseCaching:基于 VaryByHeader 定制缓存 Key
  16. Android studio 中的TabWidget
  17. WebAPI使用Token进行验证
  18. pandas中一列含有多种数据类型的转换:科学计算法转浮点数、字符映射
  19. Android获取文件夹下的所有子文件名称;
  20. $.AJAX参数提交及后台获取方式

热门文章

  1. 【NOIP2011 Day 1】选择客栈
  2. [JXOI 2018] 守卫 解题报告 (DP)
  3. Laravel-查询作用域
  4. H3BPM实例分享——金额规则大写
  5. 同一sql程序执行比数据库执行慢
  6. winFrom线程
  7. ESLint 规范项目代码
  8. mach-o格式分析
  9. 面试官:为什么mysql不建议执行超过3表以上的多表关联查询?
  10. Spring cloud父项目的建立