您的位置:首页 > 其它

[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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  poj 学生党