POJ 2350 Above Average
Description
Input
Output
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的更多相关文章
- Poj 2350 Above Average(精度控制)
一.Description It is said that 90% of frosh expect to be above average in their class. You are to pro ...
- poj 2833 The Average(堆)
题目链接:http://poj.org/problem?id=2833 思路分析:由于数据量较大,超出存储范围,使用不能使用数组存储数据在进行排序.考虑维护一个最大堆与最小堆,依次读取数据, 记录数据 ...
- POJ 2833 The Average(优先队列)
原题目网址:http://poj.org/problem?id=2833 本题中文翻译: 描述 在演讲比赛中,当选手完成演讲时,评委将对他的演出进行评分. 工作人员删除最高成绩和最低成绩,并计算其余成 ...
- POJ 2350
#include<iostream> #include<stdio.h> #include<iomanip> using namespace std; int ma ...
- POJ 题目分类(转载)
Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...
- (转)POJ题目分类
初期:一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. ...
- poj分类
初期: 一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. ( ...
- poj 题目分类(1)
poj 题目分类 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K--0.50K:中短代码:0.51K--1.00K:中等代码量:1.01K--2.00K:长代码:2.01 ...
- POJ题目分类(按初级\中级\高级等分类,有助于大家根据个人情况学习)
本文来自:http://www.cppblog.com/snowshine09/archive/2011/08/02/152272.spx 多版本的POJ分类 流传最广的一种分类: 初期: 一.基本算 ...
随机推荐
- python下实现汉诺塔
汉诺塔是印度一个古老传说的益智玩具.汉诺塔的移动也可以看做是递归函数. 我们对柱子编号为a, b, c,将所有圆盘从a移到c可以描述为: 如果a只有一个圆盘,可以直接移动到c: 如果a有N个圆盘,可以 ...
- ORA-01940无法删除当前已连接用户
原文地址:ORA-01940无法删除当前已连接用户作者:1736188794 1)查看用户的连接状况 select username,sid,serial# from v$session ------ ...
- DB2表是否存在
select count(1) from syscat.tables where tabname='T1';
- 在转换为 UTC 时大于 DateTime.MaxValue 或小于 DateTime.MinValue 的 DateTime 值无法系列化为 JSON
看到这个错往往会感到莫名其妙! 其原因其实是数据库的DateTime最小值和C#的DateTime不一样 Sql Server DateTime 类型必须介于 1/1/1753 12:00:00 AM ...
- javascript 事件委托 和jQuery事件绑定on、off 和one
一. 事件委托什么是事件委托?用现实中的理解就是:有100 个学生同时在某天中午收到快递,但这100 个学生不可能同时站在学校门口等,那么都会委托门卫去收取,然后再逐个交给学生.而在jQuery 中, ...
- Linux网络管理之net-tools VS iproute2
查看网卡及IP ifconfig ip link [show] --------- ifconfig -a ip addr show 激活和停止网络接口 ifconfig eth0 up/down i ...
- wuzhicms 数据迁移策略
1,本地的域名或ip为特殊域名或ip,勿用 127.0.0.1 或 localhost 或192.168.1.101 等 2,导出数据库,替换所有域名为新域名 3,替换所有文件域名为新域名 4, ...
- 【ARM】S3C6410芯片的启动流程
S3C6410芯片的启动流程 (1) 上电后首先运行iRom(BL0)内的代码,主要完成时钟和看门狗等外围器件的初始化.(2) 拷贝SD卡或者NnadFlash中的前4k(BL1)代码到片内ram(垫 ...
- dplyr 数据操作 常用函数(3)
接下了我们继续了解dplyr中有用的函数 1.if_else() if_else主要用于在数据做判断用 x<-data.frame(id=1:6, name=c("wang" ...
- 使用recordmydesktop进行屏幕录像
屏幕录像的功能对于分享游戏攻略.演示电脑软件的操作是必不可少的.在Windows下可能一般的用户就下载盗版的商业软件来做了.而在GNU/Linux操作系统下,则有现成的自由软件可供使用,只不过没有图形 ...