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 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
随机推荐
- 利用Python覆盖图像的某一部分,即改变图形一块区域(Region)的RGBA值
原图如下: 改变过后的图如下: 查阅API写法如下: from PIL import Image from PIL import ImageDraw pilim = Image.open('1.jpg ...
- Leetcode414Third Maximum Number第三大的数
给定一个非空数组,返回此数组中第三大的数.如果不存在,则返回数组中最大的数.要求算法时间复杂度必须是O(n). 示例 1: 输入: [3, 2, 1] 输出: 1 解释: 第三大的数是 1. 示例 2 ...
- C++类中的枚举类型
在看effective c++的时候,其中第二条边指出.尽量使用const ,enum代替define.在写程序的时候,需要入参为设备类型,第一反应是枚举一个设备类型,并以名字命名.但是有一个问题挺困 ...
- vue如何发请求
1.vue 支持开发者引入 jquery 使用 $.ajax() 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1.首先,在 package.json 中添加 j ...
- 使用Python的requests库作接口测试——请求对象与响应对象
任何时候调用requests.*()操作接口时,我们都在做两件事情: 1.构建一个Request对象,该对象被发送到服务器去请求或查询一些资源: 2.一旦requests得到一个从服务器返回的响应,就 ...
- Django项目:CRM(客户关系管理系统)--43--35PerfectCRM实现CRM重写Admin密码修改
#admin.py # ————————01PerfectCRM基本配置ADMIN———————— from django.contrib import admin # Register your m ...
- mac mamp host 配置
<VirtualHost *:80> DocumentRoot "/Users/xuxu/www" ServerName localhost <Directory ...
- iphone越狱开发之Class-Dump
刚刚开始接触ios越狱开发,现在开始纪录每天的点滴进展 装载请注明 http://www.cnblogs.com/xiongwj0910/archive/2012/08/16/2642988.html ...
- Pull Request的过程、基于git做的协同开发、git常见的一些命令、git实现代码的review、git实现版本的管理、gitlab、GitHub上为开源项目贡献代码
前言: Pull Request的流程 1.fork 首先是找到自己想要pull request的项目, 然后点击fork按钮,此时就会在你的仓库中多出来一个仓库,格式是:自己的账户名/想要pull ...
- python基--re模块的使用
正则表达式: 正则表达式本身是一种小型的.高度专业化的编程语言,然而在python中,通过内嵌集成re模块让调用者们可以直接调用来实现正则匹配.正则表达模式被变异成一系列的字节码,然后由C语言编写的 ...