- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- srand(time(NULL));
- int steps[] = { 0,0,0,0 };
- string shape[] = { "◆","★","▲","●" };
- int round = 0, balance = 0, choose, horse,plus,lost=0,win=0,num=0;
- int w=0,ran;
- re:
- system("cls");
- cout << "馬場大廳-----------" << endl;
- cout << "馬荷包餘額:" << balance<<"\n<1> 儲值 <2>下注 <3>離開\n請選擇:";
- cin >> choose;
- switch (choose)
- {
- case 1:
- cout << "請輸入儲值金額:";cin >> plus;
- if (plus <= 0)
- {
- cout << "輸入錯誤,即將返回大廳" << endl;
- _sleep(1500);
- goto re;
- }
- balance += plus;plus = 0;
- cout << "已儲值" << endl;
- goto re;
- break;
- case 2:
- cout << "請選擇下注金額:";cin >> plus;
- lost+=plus;
- if (plus > balance||plus<=0)
- {
- cout << "輸入錯誤,即將返回大廳" << endl;
- _sleep(1500);
- goto re;
- }
- cout << "<1>◆ <2>★ <3>▲ <4>●\n請選擇馬匹:";cin >> horse;
- if (horse >= 5 || horse <= 0)
- {
- cout << "輸入錯誤,即將返回大廳" << endl;
- _sleep(1500);
- goto re;
- }
- horse = horse - 1;
- break;
- case 3:
- num=-lost+win;
- if(num<0)
- cout<<"你今天共陪了:"<<-num<<"元"<<endl;
- else
- cout << "你的馬錢包金額" << balance << "元已轉至你的錢包\n" << endl;
- system("pause");
- return 0;
- }
- cout << "超坑錢賽馬場" << endl;
- cout << "-------------------------------------------------------------------------|終點";
- _sleep(2000);
- while (w <= 71)
- {
- cout << "比賽進行中" << endl;
- cout << "-------------------------------------------------------------------------|終點" << endl;
- steps[rand() % 4] += 1;
- ran = rand() % 4;
- w = steps[ran];
- for (int u = 0;u <= 3;u++)
- {
- for (int s = 0;s <= steps[u];s++)
- {
- cout << " ";
- }
- cout << shape[u] << endl;
- }
- _sleep(1);
- if (w == 71)
- {
- cout << shape[ran] << "勝利!\n" << endl;
- if (ran == horse)
- {
- cout << "你選擇的馬匹勝利了!\n" << "你共下注了:" << plus << "元\n恭喜賺了"
- << plus * 9 << "元" << endl;
- balance += plus * 10;
- win+=plus*10;
- plus = 0;
- _sleep(2000);
- goto re;
- }
- else
- {
- cout << "你選擇的馬匹並沒有贏...\n" << "你共賠了:" << plus << "元" << endl;
- balance -= plus;lost+=plus;plus=0;
- _sleep(2000);
- goto re;
- }
- }
- system("cls");
- }
- }
複製代碼 |