- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int r=0, n=1, b, buy, option, bet, option2;
- re:
- system("cls");
- srand(time(NULL));
- int s[]={0,0,0,0};
- string p[]={"◆","★","▲","●"};
- cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<4; i++)
- {
- cout<<p[i]<<endl;
- }
- cout<<"餘額"<<b<<"元"<<endl;
- cout<<"(1)儲值(2)下注(3)離開 請選擇:";
- cin>>option;
- if(option==1)
- {
- cout<<"儲值:";
- cin>>buy;
- if(buy>=1)
- {
- b=b+buy;
- goto re;
- }
- else if(buy<=0)
- {
- cout<<"輸入錯誤"<<endl;
- _sleep(1500);
- goto re;
- }
- }
- if(option==2)
- {
- cout<<"下注:";
- cin>>bet;
- if(bet<=b)
- {
- b=b-bet;
- cout<<"(1)◆(2)★(3)▲(4)● 請選擇"<<endl;
- cin>>option2;
- cout<<"比賽即將開始....."<<endl;
- _sleep(1500);
- }
- else if(bet>b)
- {
- cout<<"可用餘額不足,請先買入!"<<endl;
- _sleep(1500);
- goto re;
- }
- else if(bet<=0)
- {
- cout<<"輸入錯誤"<<endl;
- _sleep(1500);
- goto re;
- }
- }
- else if(option==3)
- {
- goto end;
- }
- else
- {
- cout<<"輸入錯誤"<<endl;
- _sleep(1500);
- goto re;
- }
- system("pause");
- system("cls");
- while(s[r]<=73)
- {
- r=rand()%4;
- s[r]++;
- cout<<"比賽進行中"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<4; i++)
- {
- for(int j=0; j<s[i]; j++)
- cout<<" ";
- cout<<p[i]<<endl;
- }
- _sleep(50);
- system("cls");
- }
- cout<<"比賽結束 "<<p[r]<<"贏"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<4; i++)
- {
-
- for(int j=0; j<s[i]; j++)
- cout<<" ";
- cout<<p[i]<<endl;
- }
- if(option2-1==r)
- {
- cout<<"賭贏"<<bet*3<<"元"<<endl;
- b=b+bet*3;
- }
- else
- {
- cout<<"賭輸"<<bet<<"元"<<endl;
- b-=bet;
- }
- n++;
- system("pause");
- goto re;
- end:
- return 0;
- }
複製代碼 |