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