- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- srand(time(NULL));
- int x=1,balance=0,option,buyin,bet,player,wallet=0;
- re:
- system("cls");
- string n[]={"◆","★","▲","●"};
- int s[]={0,0,0,0};
- int r;
- cout<<"「好事成雙」賽馬場 第"<<x<<"局"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<4; i++)
- cout<<n[i]<<endl;
- cout<<endl<<"可用餘額: "<<balance<<"元"<<endl<<endl;
- cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
- cin>>option;
- if(option==1)
- {
- cout<<"買入: ";
- cin>>buyin;
- if(buyin<=0)
- {
- cout<<"輸入錯誤!"<<endl;
- _sleep(1500);
- goto re;
- }
- balance+=buyin;
- goto re;
- }else if(option==2)
- {
- cout<<"下注: ";
- cin>>bet;
- if(bet<=0)
- {
- cout<<"輸入錯誤!"<<endl;
- _sleep(1500);
- goto re;
- }
- if(bet>balance)
- {
- cout<<"可用餘額不足,請先買入!"<<endl;
- _sleep(1500);
- goto re;
- }
- cout<<endl<<"(1)◆ (2)★ (3)▲ (4)● 請選擇: ";
- cin>>player;
- cout<<"比賽即將開始..."<<endl<<endl;
- }else if(option==3)
- {
- goto end;
- }else
- {
- cout<<"輸入錯誤!"<<endl;
- _sleep(1500);
- goto re;
- }
- system("pause");
- while(true)
- {
- cout<<"比賽進行中"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- r=rand()%4;
- s[r]++;
- for(int i=0; i<4; i++)
- {
- for(int j=0; j<s[i]; j++)
- cout<<" ";
- cout<<n[i]<<endl;
- }
- _sleep(10);
- system("cls");
- if(s[r]==76)
- break;
- }
- cout<<"比賽結果! 由 "<<n[r]<<" 先馳得點!"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<4; i++)
- {
- for(int j=0; j<s[i]; j++)
- cout<<" ";
- cout<<n[i]<<endl;
- }
- if(player-1==r)
- {
- cout<<"贏了 "<<bet*3<<"元!";
- balance+=bet*3;
- wallet+=bet*3;
- }else
- {
- cout<<"損失 "<<bet<<"元";
- balance-=bet;
- wallet-=bet;
- }
- cout<<endl<<endl;
- system("pause");
- x++;
- goto re;
- end:
- cout<<endl;
- if(wallet==0)
- cout<<"沒輸沒贏! 全身而退!"<<endl<<endl;
- else if(wallet>0)
- cout<<"恭喜你! 這次總共贏了"<<wallet<<"元!"<<endl<<endl;
- else
- cout<<"不好意思! 讓你損失了"<<-wallet<<"元!"<<endl<<endl;
- cout<<"謝謝光臨! 下次再來!"<<endl<<endl;
- system("pause");
- return 0;
- }
複製代碼 |