2011-02-13 62 views
0

我試圖創建三個插槽的簡單老虎機。每個插槽將生成一個介於0和9之間的隨機數。用戶將以1,000個硬幣開始,並且可以每插槽拉下任意數量的硬幣。支出爲:如果兩個插槽相等,則用戶贏得10倍投注,如果3個插槽相等,則用戶贏得100倍投注,並且如果0個插槽相等,則用戶失去投注。我想輸出一般看起來像這樣:基本老虎機

老虎機
你有1000個硬幣。
按0鍵退出,任何其他數字播放每旋許多硬幣
旋轉:4 6 6
你贏了10000枚硬幣!你現在有11000個硬幣。
按0鍵退出,任何其他數字播放每旋許多硬幣
旋轉:4 4 1
你贏了110000個金幣!你現在有121000個硬幣。
按0鍵退出,任何其他數字播放每旋許多硬幣
旋轉:5 1 9
你輸了121000個金幣!你現在有0個硬幣。
按0退出,任何其他號碼每旋轉一次可播放多個硬幣
用完了硬幣。感謝參與。

我對編程不是很熟悉,而且我照顧的一些老年人會享受這一點,以便他們學習如何使用計算機。謝謝。

+0

問題需要一個標籤「好'醇天:) – bestsss 2011-02-13 01:00:40

+0

我想它不是讓他們的鬆*實際*一武裝匪徒更好。 – 2011-02-13 01:35:02

回答

0

就像這樣(僞代碼)。添加適當的報表打印,錯誤檢查等

coins = 1000 

while (coins > 0) 
{ 
    input wager 
    if wager > coins 
     wager = coins 
    if wager <= 0 
     exit 

    slot1 = rand(0..9) 
    slot2 = rand(0..9) 
    slot3 = rand(0..9) 

    if (slot1 == slot2 and slot2 == slot3) 
     coins = coins + (100 * wager) 
    else if (slot1 == slot2 or slot2 == slot3 or slot1 == slot3) 
     coins = coins + (10 * wager) 
    else 
     coins = coins - wager 
} 

You're broke ... sorry