作者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
推 laymu :改成c++而已嗎? 04/29 17:25
→ ilay :嗯阿 最近要賺賭金了 GP下一場還有幾天吧 04/29 18:37
推 joujouka :我還是猴王命XD 04/29 19:53