您的位置:首页 > 其它

津津的储蓄计划

2015-08-14 22:28 204 查看
http://codevs.cn/problem/4085/

http://codevs.cn/problem/1057/

http://www.acmicpc.sdnu.edu.cn/problem/show/1170

竟然是顺序结构的题,GET到一个新技能,在递归调用时可以提前return,那么在主函数也可以提前return 啊。

这次需要注意的是,最后计算是最后一个的余额要计算上去。

#include<iostream>
#include<stdio.h>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
int cunkuan = 0;
int hand=0;
for (int i = 1; i < 13; i++)
{
int yusuan;
cin >> yusuan;
hand += 300;
if (hand<yusuan)
{
cout << "-" << i << endl;
system("pause");
return 0;
}
else{
hand -= yusuan;
cunkuan += hand - hand % 100;
hand = hand % 100;
}
}
cout << hand + cunkuan*12.0 / 10 << endl;
system("pause");
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: