A. Tutor

Description

Lilin was a student of Tonghua Normal University. She is studying at University of 

Chicago now. Besides studying, she worked as a tutor teaching Chinese to Americans. So, 

she can earn some money per month. At the end of the year, Lilin wants to know his 

average monthly money to decide whether continue or not. But she is not good at 

calculation, so she ask for your help. Please write a program to help Lilin to calculate the 

average money her earned per month.

Input

The first line contain one integer T, means the total number of cases.

Every case will be twelve lines. Each line will contain the money she earned per 

month. Each number will be positive and displayed to the penny. No dollar sign will be 

included.

Output

The output will be a single number, the average of money she earned for the twelve 

months. It will be rounded to the nearest penny, preceded immediately by a dollar sign

without tail zero. There will be no other spaces or characters in the output.

Sample Input

2

100.00

489.12

12454.12

1234.10

823.05

109.20

5.27

1542.25

839.18

83.99

1295.01

100.00

100.00

100.00

100.00

100.00

100.00

100.00

100.00

100.00

100.00

100.00

100.00

Sample Output

$1581.42

$100

比较水的一道题,就是求12个数的平均数。但加了一点小小的要求,。就是精确到2位小数,而且如果小数结尾有0,还要去掉

#include<stdio.h>
int main()
{
int t;
scanf("%d", &t);
while(t--)
{
int i;
double sum = 0;
for(i = 0; i < 12; i++)
{
double num;
scanf("%lf", &num);
sum += num;
}
char str[100];
sprintf(str, "%.2lf", sum / 12);
int j;
printf("$");
for(j= 0; str[j]; j++)
{
if(str[j] == '.')
{
if(str[j + 2] == '0')
{
if(str[j + 1] == '0')
break;
else str[j + 2] = 0;
}
}
putchar(str[j]);
}
printf("\n");
}
return 0;
}

2013 ACM 通化邀请赛 A. Tutor的更多相关文章

  1. 2013 ACM 通化邀请赛D.D-City 并查集

    点击打开链接 D.D-City Description Luxer is a really bad guy. He destroys everything he met. One day Luxer ...

  2. 2013 吉林通化邀请赛 Tutor 有点坑的水题

    计算12个数的和的平均数.四舍五入,不能有后导0. 我的做法是,将答案算出后,乘以1000,然后看个位是否大于等于5,判断是否要进位…… #include<iostream> #inclu ...

  3. 2013 吉林通化邀请赛 Play Game 记忆化搜索

    dp[ba][ta][bb][tb]表示a堆牌从下面拿了ba张,从上面拿了ta张.b堆牌从下面拿了bb张,从上面拿了tb张.当前玩家能得到的最大的分数. 扩展方式有4种,ba+1,ta+1,bb+1, ...

  4. 2013 吉林通化邀请赛 D-City 离线型的并查集

    题意:给定n个点和m条边,问你拆掉前i条边后,整个图的连同城市的数量. i从1到m. 思路:计算连通的城市,很容易想到并查集,但是题目里是拆边,所以我们可以反向去做. 存下拆边的信息,从后往前建边. ...

  5. hduoj 4710 Balls Rearrangement 2013 ACM/ICPC Asia Regional Online —— Warmup

    http://acm.hdu.edu.cn/showproblem.php?pid=4710 Balls Rearrangement Time Limit: 6000/3000 MS (Java/Ot ...

  6. hduoj 4708 Rotation Lock Puzzle 2013 ACM/ICPC Asia Regional Online —— Warmup

    http://acm.hdu.edu.cn/showproblem.php?pid=4708 Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/O ...

  7. hduoj 4715 Difference Between Primes 2013 ACM/ICPC Asia Regional Online —— Warmup

    http://acm.hdu.edu.cn/showproblem.php?pid=4715 Difference Between Primes Time Limit: 2000/1000 MS (J ...

  8. hduoj 4712 Hamming Distance 2013 ACM/ICPC Asia Regional Online —— Warmup

    http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Other ...

  9. hduoj 4706 Herding 2013 ACM/ICPC Asia Regional Online —— Warmup

    hduoj 4706 Children's Day 2013 ACM/ICPC Asia Regional Online —— Warmup Herding Time Limit: 2000/1000 ...

随机推荐

  1. python 字典访问的三种方法

    定义字典 dic = {'a':"hello",'b':"how",'c':"you"} 方法一: for key in dic: prin ...

  2. HTML 打印 javascript连续打印 分页

    page-break-after属性介绍:http://www.w3school.com.cn/cssref/pr_print_page-break-after.asp <div style=& ...

  3. javascript 对象中的 handleEvent

    在高级浏览器中,我们在绑定事件的时候 可以知道绑定一个对象,然后在这个对象中的 handleEvent 方法会自动进入指定的方法,不多说了举个例子吧!! var events = { handleEv ...

  4. SQL SERVER 组内排序

    取出每组的第一个 select *from (select * ,RANK ( ) OVER( PARTITION by org order by reportcode asc) PartionNum ...

  5. php特殊字符过滤,html标签处理

    1,magic_quotes_gpc  默认情况下,PHP 指令 magic_quotes_gpc 为 on,对所有的 GET.POST 和 COOKIE 数据自动运行 addslashes().不要 ...

  6. erlang的shell历史记录

    erlang的shell默认重启以后木有历史记录,略蛋疼,开发的时候略不便 网上找了个方式 sudo apt-get install rlwrap vim ~/.bash_profile alias ...

  7. hostapd移植与使用

    介绍 版本:hostapd-2.5.tar.gz 下载地址:http://w1.fi/releases/hostapd-2.5.tar.gz 依赖:libnl openssl 移植 libnl移植 w ...

  8. vs 引用sqlite的问题

    错误 4 未能找到类型或命名空间名称“SQLiteCommand”(是否缺少 using 指令或程序集引用?) D:\01学习\SQLite\HBZCSCXT_Mobile\SqlLiteHelper ...

  9. SVN在团队项目中的使用技巧:[2]Tag操作

    SVN是Subversion的简称,是一个开放源代码的版本控制系统 本节讲述SVN使用中的TAG操作 文中若有错误或不足之处,欢迎留言指正   工具/原料 电脑 SVN 方法/步骤 1.认识SVN中T ...

  10. memcached应用场景(转)

     memcached最吸引人的地方主要在于它的分布式.分布式对于互联网应用来讲,按照用途基本上可划分为三种方式:分布式计算.分布式存储和两者兼而有之.memcached是分布式存储的一种.我们常见的分 ...