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

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% 简单题 求分数超过平均分的学生的比例
来看一下WA和AC的代码
下面是WA的
 #include<stdio.h>
int sco[+];
int main()
{
int T,n,i;
double ave;
double res;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
ave=0.0;res=0.0;
for(i=;i<n;i++)
{
scanf("%d",&sco[i]);
ave+=double(sco[i]);
}
ave/=double(n);
for( i=;i<n;i++)
{
if(sco[i]>ave)res+=1.0;
}
res/=n;res*=;
printf("%.3lf%%\n",res);
}
return ;
}

下面是AC的

 #include<stdio.h>
int sco[+];
int main()
{
int T,n,i;
float ave;
float res;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
ave=0.0;res=0.0;
for(i=;i<n;i++)
{
scanf("%d",&sco[i]);
ave+=float(sco[i]);
}
ave/=float(n);
for( i=;i<n;i++)
{
if(sco[i]>ave)res+=1.0;
}
res/=n;res*=100.0;
printf("%.3f%%\n",res);
}
return ;
}

就是把double改成了float......

												

POJ 2350 Above Average的更多相关文章

  1. Poj 2350 Above Average(精度控制)

    一.Description It is said that 90% of frosh expect to be above average in their class. You are to pro ...

  2. poj 2833 The Average(堆)

    题目链接:http://poj.org/problem?id=2833 思路分析:由于数据量较大,超出存储范围,使用不能使用数组存储数据在进行排序.考虑维护一个最大堆与最小堆,依次读取数据, 记录数据 ...

  3. POJ 2833 The Average(优先队列)

    原题目网址:http://poj.org/problem?id=2833 本题中文翻译: 描述 在演讲比赛中,当选手完成演讲时,评委将对他的演出进行评分. 工作人员删除最高成绩和最低成绩,并计算其余成 ...

  4. POJ 2350

    #include<iostream> #include<stdio.h> #include<iomanip> using namespace std; int ma ...

  5. POJ 题目分类(转载)

    Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...

  6. (转)POJ题目分类

    初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推. ...

  7. poj分类

    初期: 一.基本算法:      (1)枚举. (poj1753,poj2965)      (2)贪心(poj1328,poj2109,poj2586)      (3)递归和分治法.      ( ...

  8. poj 题目分类(1)

    poj 题目分类 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K--0.50K:中短代码:0.51K--1.00K:中等代码量:1.01K--2.00K:长代码:2.01 ...

  9. POJ题目分类(按初级\中级\高级等分类,有助于大家根据个人情况学习)

    本文来自:http://www.cppblog.com/snowshine09/archive/2011/08/02/152272.spx 多版本的POJ分类 流传最广的一种分类: 初期: 一.基本算 ...

随机推荐

  1. mvc架构和mvp架构

    mvc,mvp其实是复合模式,是多个设计模式的组合:将多个模式结合起来形成一个框架,已解决一般性问题. mvc: 既然mvc是复合模式,那么是由哪些设计模式组合的呢? 观察者设计模式:view和con ...

  2. 仿qq的侧拉菜单效果

    自定义控件 import android.animation.ArgbEvaluator; import android.animation.FloatEvaluator; import androi ...

  3. python3的文件读写模式

    任何一种语言,文件的读写都是非常常见的.python的文件读写非常简单,仅仅一个函数open(file也可以,但是我不常用). 先看看官网的解释: open(file, mode='r', buffe ...

  4. Pos终端中的主密钥、工作密钥、pin密钥、mac密钥

    下面介绍一下加密机中最主要的几种密钥: 1.加密机主密钥(MK) 加密机主密钥(Master Key - MK)是存入在HSM机内的由三个成分合成的一对最上层密钥.在HSM机器以外的地方不会以明文形式 ...

  5. >> 计算机的数据表示

    1. 采用二进制 2. 负数采用补码表示 3. 乘法处理 4. 浮点数

  6. iOS中的布局

    1.UIView 有三个比较重要的布局属性: frame , bounds 和 center , CALayer 对应地叫做 frame , bounds 和 position .为了能清楚区分,图层 ...

  7. NYOJ-括号配对问题 <技巧性的非栈道法>

    括号配对问题 时间限制:3000 ms  |  内存限制:65535 KB 难度:3  描述 现在,有一行括号序列,请你检查这行括号是否配对. 输入 第一行输入一个数N(0<N<=100) ...

  8. POJ 3507 Judging Olympia

    小技巧 判断 全部为零 用sign和所有元素依次取或 排除最大项和最小项 直接排序后取中间的四个元素 http://poj.org/problem?id=3507 1 #include <ios ...

  9. Linux下重置MySQL的Root帐号密码

    1.停止MySQL服务 /etc/init.d/mysqld stop 2.跳过验证启动MySQL /usr/local/mysql/bin/mysqld_safe --skip-grant-tabl ...

  10. Chapter 2 Open Book——32

    I paused for a long moment, and then made the mistake of meeting his gaze. 我停顿了很长时间,然后错误的去对视了他的凝视 我停 ...