与1141题相同。

时间限制:1 秒

内存限制:32 兆

特殊判题:否

提交:843

解决:502

题目描述:

Larry graduated this year and finally has a job. He's making a lot of money, but somehow never seems to have enough. Larry has decided that he needs to grab hold of his financial portfolio and solve his financing problems. The first step is to figure out
what's been going on with his money. Larry has his bank account statements and wants to see how much money he has. Help Larry by writing a program to take his closing balance from each of the past twelve months and calculate his average account balance.

输入:

Each case will be twelve lines. Each line will contain the closing balance of his bank account for a particular month. Each number will be positive and displayed to the penny. No dollar sign will be included.

输出:

For each case, the output will be a single number, the average (mean) of the closing balances for the twelve months. It will be rounded to the nearest penny, preceded immediately by a dollar sign, and followed by the end-of-line. There will be no other
spaces or characters in the output.

样例输入:
  1. 100.00
  2. 489.12
  3. 12454.12
  4. 1234.10
  5. 823.05
  6. 109.20
  7. 5.27
  8. 1542.25
  9. 839.18
  10. 83.99
  11. 1295.01
  12. 1.75
样例输出:
  1. $1581.42
来源:
2010年北京大学计算机研究生机试真题

代码:

  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5. int n, i;
  6. double cost;
  7. double sum;
  8.  
  9. while (scanf("%lf", &cost) != EOF)
  10. {
  11. sum = cost;
  12. for(i=1; i<12; i++)
  13. {
  14. scanf("%lf", &cost);
  15. sum += cost;
  16. }
  17. printf("$%.2lf\n", sum/12);
  18. }
  19.  
  20. return 0;
  21. }
  22. /**************************************************************
  23. Problem: 1148
  24. User: liangrx06
  25. Language: C
  26. Result: Accepted
  27. Time:0 ms
  28. Memory:912 kb
  29. ****************************************************************/

九度OJ 1148:Financial Management(财务管理) (平均数)的更多相关文章

  1. 九度oj 题目1087:约数的个数

    题目链接:http://ac.jobdu.com/problem.php?pid=1087 题目描述: 输入n个整数,依次输出每个数的约数的个数 输入: 输入的第一行为N,即数组的个数(N<=1 ...

  2. 九度OJ 1502 最大值最小化(JAVA)

    题目1502:最大值最小化(二分答案) 九度OJ Java import java.util.Scanner; public class Main { public static int max(in ...

  3. 九度OJ,题目1089:数字反转

    题目描述: 12翻一下是21,34翻一下是43,12+34是46,46翻一下是64,现在又任意两个正整数,问他们两个数反转的和是否等于两个数的和的反转. 输入: 第一行一个正整数表示测试数据的个数n. ...

  4. 九度OJ 1500 出操队形 -- 动态规划(最长上升子序列)

    题目地址:http://ac.jobdu.com/problem.php?pid=1500 题目描述: 在读高中的时候,每天早上学校都要组织全校的师生进行跑步来锻炼身体,每当出操令吹响时,大家就开始往 ...

  5. 九度OJ 1531 货币面值(网易游戏2013年校园招聘笔试题) -- 动态规划

    题目地址:http://ac.jobdu.com/problem.php?pid=1531 题目描述: 小虎是游戏中的一个国王,在他管理的国家中发行了很多不同面额的纸币,用这些纸币进行任意的组合可以在 ...

  6. 九度OJ 1024 畅通工程 -- 并查集、贪心算法(最小生成树)

    题目地址:http://ac.jobdu.com/problem.php?pid=1024 题目描述:     省政府"畅通工程"的目标是使全省任何两个村庄间都可以实现公路交通(但 ...

  7. 九度OJ 1371 最小的K个数 -- 堆排序

    题目地址:http://ac.jobdu.com/problem.php?pid=1371 题目描述: 输入n个整数,找出其中最小的K个数.例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4 ...

  8. 九度OJ 题目1384:二维数组中的查找

    /********************************* * 日期:2013-10-11 * 作者:SJF0115 * 题号: 九度OJ 题目1384:二维数组中的查找 * 来源:http ...

  9. hdu 1284 关于钱币兑换的一系列问题 九度oj 题目1408:吃豆机器人

    钱币兑换问题 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Sub ...

随机推荐

  1. 已知一个序列A1.A2….An,给你一个整数K,找到满足所有Ai+Aj>=k的数对(i,j)的个数

    #include<bits/stdc++.h> using namespace std; #define ll long long #define maxn 100010 /* 已知一个序 ...

  2. Implement Trie (Prefix Tree) - LeetCode

    Implement a trie with insert, search, and startsWith methods. Note:You may assume that all inputs ar ...

  3. 某考试 T1 fair (18.5.1版)

    转化一下模型:每天可以选1也可以选0,但是任意前i天(i<=n)1的个数都必须>=0的个数,求总方案数/2^n. 然后可以发现这是一个经典题,随便推一下公式发现等于  C(n,n/2)/2 ...

  4. SpringMVC_01:创建运行环境(Maven)

    Maven 环境下配置: 1.新建MavenProject,打包选线根据情况选择jar war和pom jar:打包为jar包,主要用于被其他项目引用 war:打包为war包,可直接运行于服务器 po ...

  5. 一款不错的编程字体Source Code Pro

    我以前一直是用的MS自家的是Consolas的字体,这个字体基本上具有编程字体所需的所有要素:等宽.支持ClearType.中文字体大小合适,l和1,o和0很容易区分.非要挑刺的话就是字体比较小,9号 ...

  6. many-to-one多对一属性说明

    通过many-to-one元素,可以定义一种常见的与另一个持久化类的关联. 这种关系模型是多对一关联(实际上是一个对象引用-译注):这个表的一个外键引用目标表的 主键字段. <many-to-o ...

  7. LeetCode 290 Word Pattern(单词模式)(istringstream、vector、map)(*)

    翻译 给定一个模式,和一个字符串str.返回str是否符合同样的模式. 这里的符合意味着全然的匹配,所以这是一个一对多的映射,在pattern中是一个字母.在str中是一个为空的单词. 比如: pat ...

  8. 【Java编程】JDBC注入攻击-Statement 与 PreparedStatement

    在上一篇[Java编程]建立一个简单的JDBC连接-Drivers, Connection, Statement and PreparedStatement我们介绍了怎样使用JDBC驱动建立一个简单的 ...

  9. TP多条件查询

    $stcount = M("Results_all")->alias('a') ->join("s_test_name as b on a.subject = ...

  10. 怎样使用 iOS 7 的 AVSpeechSynthesizer 制作有声书(3)

    plist 中的每一页 utteranceSting 我们都创建了一个RWTPage.displayText.因此,每页的文本会一次性地显示出来. 由于 You've constructedeach ...