Hdu 4493
注意四舍五入,保留到小数点后两位(如果存在的话)。
附上代码:
- /*************************************************************************
- > File Name: 4493.cpp
- > Author: Stomach_ache
- > Mail: sudaweitong@gmail.com
- > Created Time: 2014年05月19日 星期一 22时39分19秒
- > Propose:
- ************************************************************************/
- #include <cmath>
- #include <string>
- #include <cstdio>
- #include <fstream>
- #include <cstring>
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int
- main(void) {
- int t;
- scanf("%d", &t);
- while (t--) {
- double avg = 0.0;
- for (int i = ; i < ; i++) {
- double a;
- scanf("%lf", &a);
- avg += a;
- }
- avg /= ;
- char str[];
- // 四舍五入
- sprintf(str, "$%.2f", avg);
- int len = strlen(str);
- if (str[len-] == '' && str[len-] == '') {
- str[len-] = '\0';
- } else if (str[len-] == '') {
- str[len-] = '\0';
- }
- puts(str);
- }
- return ;
- }
Hdu 4493的更多相关文章
- hdu 4493 Tutor 水题
Tutor Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4493 D ...
- HDU 4493 Tutor 水题的收获。。
题目: http://acm.hdu.edu.cn/showproblem.php?pid=4493 题意我都不好意思说,就是求12个数的平均数... 但是之所以发博客,显然有值得发的... 这个题最 ...
- hdu 4493 Tutor
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4493 给你十二个月的工资,算平均数,保留两位,去除末尾的0 使用暴力解决,嘻嘻,但是这题主要是在进位这个地 ...
- HDU 4493 Tutor(精度处理)
题目 #include<stdio.h> int main() { int t; double a,s; scanf("%d",&t); while(t--) ...
- HDU 4493 Tutor (控制精度)
题意:给定12个数,求平均数. 析:这个题就是精度控制问题,如果控制精度,最好的办法就是用整型了. 代码如下: #include <cstdio> #include <string& ...
- HDU 4493 Tutor (水题)
Tutor Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submi ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
随机推荐
- Django-rest Framework(四)
序列化模块时rest-framework的很重要的组成部分 rest-framework序列化模块(核心) 一. 为什么要使用序列化组件? 后台的数据多以后台的对象存在,经过序列化后,就可以格式化 ...
- ECMAScript 5 严格模式
1. 变量必须使用var声明,杜绝不小心将本地变量声明成一个全局变量 在常规模式下,如果我们声明一个变量时省略了var关键字,解析引擎会自动将其声明为全局变量,但在严格模式下,会直接抛出异常,不会为我 ...
- SpringBoot防XSS攻击
1 . pom中增加依赖 <!-- xss过滤组件 --> <dependency> <groupId>org.jsoup</groupId> < ...
- mybatis学习:mybatis的注解开发和编写dao实现类的方式入门
一.使用注解则不需要创建映射配置文件:即xxxDao.xml javaBean为什么要实现Serializable接口? Java的"对象序列化"能让你将一个实现了Serializ ...
- C++ base64 opencv Mat 转换
static std::string base64Decode(const char* Data, int DataByte) { //解码表 const char DecodeTable[] = { ...
- CF549G Happy Line
传送门 解题思路 题意大概就是给你个数列,你可以随意交换i,i+1,交换后位于第i+1位的数字+1,位于第i位的数字-1,问最终能否形成一个不下降序列并输出.设初始数列中两个位置x,y最终交换后的位置 ...
- vue组件与路由的使用步骤
router:根据不同的地址跳转到不同的页面一.vue-router的使用 1.下载路由模块 npm vue-router --save 2.在router.js中 先引入路由 imp ...
- cocos2d::ui::TextField 调用setAttachWithIME和setDetachWithIME都无效
http://www.cocoachina.com/bbs/read.php? tid=178406 看三楼: static_cast<CCTextFieldTTF*>(textField ...
- 使用Workstation虚拟机部署Linux操作系统
一.安装虚拟机: 1.安装VMware Workstation; 2.选择主页.点创建新的虚拟机: 3.选择“典型”然后点下一步: 4.选择稍后安装操作系统: 5.客户机从左系统选择“Linux”版本 ...
- GYM 101350 F. Monkeying Around
F. Monkeying Around time limit per test 2.0 s memory limit per test 256 MB input standard input outp ...