杭电acm--1064
2015-10-13 22:33
435 查看
[align=left]Problem Description[/align]
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.
[align=left]Input[/align]
The input 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.
[align=left]Output[/align]
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.
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.
[align=left]Input[/align]
The input 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.
[align=left]Output[/align]
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.
#include<stdio.h> #include<stdlib.h> #include<iostream> #include<cmath> #include<iomanip> //#define P 3.141592653 using namespace std; void main() { double avg, sum=0.0, arr[12]; for (int i = 0; i < 12; i++) { cin >> arr[i]; sum += arr[i]; } avg = sum / 12; cout <<'$'<< fixed<<setprecision(2) << avg<<endl; system("pause"); }
相关文章推荐
- parseInt中的转换细节
- Item 39:明智地使用private继承 Effective C++笔记
- 我读过的最好的epoll讲解
- 选择排序——堆排序
- 字节流和字符流详解
- 文章标题
- 如何跳过Nexus 7二代的开机设置
- 黑马程序员——java基础之多线程
- java23种设计模式之适配器模式(Adapter)
- OC中的NSDate
- 讨论内外边距对行内元素是否起作用,则要对行内替换元素和行内非替换元素分别讨论:
- hdu5131 贪心
- hdu5137 枚举删点
- PIC驱动继电器
- [转]ArrayList和HashTable 使用
- 总结Java垃圾回收器的方法和原理
- jQuery 获取屏幕高度、宽度
- mac远程桌面连接无法验证您希望连接的计算机的身份
- Graphics View Framework 简介
- css选择器