作者ilay (take it easy)
看板STU
标题Re: [闲聊] 题目看起来很简单的数学问题…资工或金 …
时间Wed Apr 29 17:21:38 2009
#include <iostream>
using namespace std;
int main()
{
int buy = 10 , sell = 5 , mony = 50 ;
int x = 0 , total = 0 , tree = 0 , buytime = 10 ;
// Round 0
cout << total << "," << mony << "," << tree << endl;
while ( mony <= 1000 )
{
total++ ;
if ( tree * sell + mony >= 1000 )
{
mony = tree * sell + mony;
tree = 0;
}
else if( mony / buytime > 0 )
{
tree = tree + mony / buy ;
mony = mony % buy ;
buytime = buytime * 2;
}
else
mony = mony + tree ;
cout << total << "," << mony << "," << tree << endl;
}
cout << total << endl;
cout << mony << endl;
return 0;
}
--
我承认我是来乱的 -__-
对了最後那个 system("pause") ... 非win32环境会gg
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 210.71.22.2
1F:推 laymu :改成c++而已吗? 04/29 17:25
2F:→ ilay :嗯阿 最近要赚赌金了 GP下一场还有几天吧 04/29 18:37
3F:推 joujouka :我还是猴王命XD 04/29 19:53