POJ 2350 Above Average
2015-07-18 21:47
417 查看
Description
It is said that 90% of frosh expect to be above average in their class. You are to provide a reality check.
Input
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.
Output
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
Sample Output
It is said that 90% of frosh expect to be above average in their class. You are to provide a reality check.
Input
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.
Output
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
Sample Output
40.000% 57.143% 33.333% 66.667% 55.556%#include <iostream> #include <cstdlib> #include <cstdio> #include <cstring> using namespace std; #define maxn 1005 int n; int f[maxn]; double average; void input() { int sum = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &f[i]); sum += f[i]; } average = sum * 1.0 / n; } double work() { int num = 0; for (int i = 0; i < n; i++) if (f[i] > average) num++; return num * 100.0 / n; } int main() { int t; scanf("%d", &t); while (t--) { input(); printf("%.3f%%\n", work()); } return 0; }
相关文章推荐
- Html 5知识总结
- AFNetworking 的导入(一)
- DirectX11 创建输入布局
- CSS布局
- codeforces gym 100187M Heaviside Function
- 解决 Firefox 火狐浏览器下载 .exe 文件卡住的问题 以及关闭测试版cache2
- AYIT暑假集训大二第一周周六赛 B - 汉字统计
- 02-数组与集合之间的互相转换
- 排序算法之归并排序
- ZOJ 1940 Dungeon Master
- 【C语言】使用递归的整数输出(高位到低位)/输出一个菱形(能够确定行数)
- boost之variant使用
- JavaScript匿名函数与闭包
- Myeclipse验证js语法报错
- 广义线性回归拟合教程和源码
- 德国精品软件推荐 压缩软件 WINRAR 个人版终于免费了。
- ScrollView
- ZOJ 1003 Crashing Balloon
- html5消除方块游戏总结-对象
- 《机器学习实战》课程笔记(第2章) k-近邻算法