[Poj1004]Financial Management
2015-10-08 21:22
323 查看
新人来了,先水一道PKU上的大水题吧。。。
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.
思路:没什么好说的,真的是很水。无非是循环一遍读入及求和,最后取平均数。。。
就是要注意使用double类型。。。
#include<iostream>
#include<iomanip>
using namespace std;
double a[13],sum,ans;
int main()
{
int i;
sum=0;
for(i=1;i<=12;i++)
{
cin>>a[i];
sum+=a[i];
}
ans=sum/12.0;
cout<<"$";
cout<<fixed<<setprecision(2)<<ans<<endl;
}
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.
思路:没什么好说的,真的是很水。无非是循环一遍读入及求和,最后取平均数。。。
就是要注意使用double类型。。。
#include<iostream>
#include<iomanip>
using namespace std;
double a[13],sum,ans;
int main()
{
int i;
sum=0;
for(i=1;i<=12;i++)
{
cin>>a[i];
sum+=a[i];
}
ans=sum/12.0;
cout<<"$";
cout<<fixed<<setprecision(2)<<ans<<endl;
}
相关文章推荐
- POJ ACM 1001
- POJ ACM 1002
- POJ 2635 The Embarrassed Cryptographe
- POJ 3292 Semi-prime H-numbers
- POJ 2773 HAPPY 2006
- POJ 3090 Visible Lattice Points
- POJ-2409-Let it Bead&&NYOJ-280-LK的项链
- POJ-1695-Magazine Delivery-dp
- POJ1523 SPF dfs
- POJ-1001 求高精度幂-大数乘法系列
- POJ-1003 Hangover
- POJ-1004 Financial Management
- 用单调栈解决最大连续矩形面积问题
- 2632 Crashing Robots的解决方法
- 1573 Robot Motion (简单题)
- POJ 1200 Crazy Search(简单哈希)
- 【高手回避】poj3268,一道很水的dijkstra算法题
- POJ 1088 滑雪
- poj2387 Til the Cows Come Home—Dijkstra模板
- poj 2485 Highways