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. [Angular Directive] Assign a Structual Directive a Dynamic Context in Angular 2

     Just like passing in an array to *ngFor, you can pass in any value into your structural directive s ...

  2. 【转】关于MySQL函数GROUP_CONCAT的使用

    GROUP_CONCAT()是MySQL数据库提供的一个函数,通常跟GROUP BY一起用,具体可参考MySQL官方文挡:http://dev.mysql.com/doc/refman/5.0/en/ ...

  3. Struts1和Struts2的区别和对比

    Struts1和Struts2的区别和对比: Action 类: • Struts1要求Action类继承一个抽象基类.Struts1的一个普遍问题是使用抽象类编程而不是接口. • Struts 2  ...

  4. trove 开发者阅读翻译

    介绍 Trove为OpenStack提供数据库的服务.它的设计运行完全符合OpenStack,目标是让用户能快速.轻松地利用关系数据库的特点,没有负担的处理复杂的管理任务.云用户和数据库管理员可以根据 ...

  5. ng1 http 读取json数据

    在前端开发过程中,有时后端还没开发出接口,需要经常自己构造获取本地mock数据. AngularJS XMLHttpRequest $http 是 AngularJS 中的一个核心服务,用于读取远程服 ...

  6. codevs3027线段覆盖2(DP)题解

    题目描述 Description 数轴上有n条线段,线段的两端都是整数坐标,坐标范围在0~1000000,每条线段有一个价值,请从n条线段中挑出若干条线段,使得这些线段两两不覆盖(端点可以重合)且线段 ...

  7. MATLAB初体验

    好激动 要入MATLAB的大坑了 恩 很遗憾第一个程序并不是hello world 好 插入代码里并没有MATLAB这个选项 这是一种歧视 x=[:pi/:*pi]; y=sin(x); plot(x ...

  8. NLog在MVC中使用

    NLog在MVC中使用 在site根目录新建NLog.config <?xml version="1.0"?> <configuration> <nl ...

  9. myeclipse启动服务器时,tomcat出错问题

    启动服务器,错误提示: Launching web on myeclipse tomcat has encountered a problem An internal error occurred d ...

  10. 第33届 MPD软件工作坊(南京站)有哪些亮点值得我们参加?

    MPD软件工作坊由msup2010年创办,自创办以来,共吸引了万名的软件从业者到场参与.第33届 MPD软件工作坊(南京站)将于12月17-18日在南京召开,大会报名平台:活动家! 快捷报名通道:ht ...