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. 设计模式 -- 桥接模式(Bridge Pattern)

    桥接模式 Bridge Pattern 结构设计模式 定义: 分离抽象部分和实现部分,使他们独立运行. 避免使用继承导致系统类个数暴增,可以考虑桥接模式. 桥接模式将继承关系转化为关联关系,减少耦合, ...

  2. 使用Redis的Java客户端Jedis

    转载自:http://aofengblog.blog.163.com/blog/static/631702120147298317919/ 前一篇文章<Redis命令指南>讲解了通过命令行 ...

  3. install plugin elasticsearch-analysis-ik

    1.github下载分词器插件(请各位下载自己elasticsearch相对应的版本,否则会有兼容性问题) https://github.com/medcl/elasticsearch-analysi ...

  4. C++ 部分知识点

    1,return语句返回函数的返回值,就是函数的类型,函数只能有唯一的返回值: return可以停止函数,并将控制返回主调函数: 一个函数可以有许多return语句,执行到哪个return语句,哪个起 ...

  5. [MFC美化] USkin使用详解-使用方法

    该种皮肤库资料很少,用法与前面几种类似. 它主要有:USkin.dll ,USkin.lib,USkin.h和Sakura.msstyles这四个文件.皮肤格式是.u3.SkinBuilder是USk ...

  6. bind() unbind()绑定解绑事件

    .bind( eventType [, eventData], handler(eventObject)) 本文实例分析了JQuery中Bind()事件用法.分享给大家供大家参考.具体分析如下: .B ...

  7. 4-Bom&Dom总结篇

    其实Bom就是指浏览器的东西,比如弹窗啊.浏览器信息啊等 而Dom则是指文档的东西,就是浏览器里边html的东西,如元素啊.属性啊.事件什么的 但Bom的唯一顶层对象window又包含Dom的顶层对象 ...

  8. Struts2的通配符配置方式

    Struts2的Action类很有意思,你可以使用3种方式来实现具体的Action类: 让你的Action类继承自ActionSupport类(项目中最常用这种方式,因为ActionSupport类中 ...

  9. C# 语言规范_版本5.0 (第17章 特性)

    1. 特性 C# 语言的一个重要特征是使程序员能够为程序中定义的实体指定声明性信息.例如,类中方法的可访问性是通过使用 method-modifiers(public.protected.intern ...

  10. winform控件跨线程委托

    1. this.listBox1.BeginInvoke(new Action(() => { if (listBox1.Items.Count > 20) listBox1.Items. ...