本帖最後由 啓銓 於 2018-6-4 20:29 編輯
- #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; //0~3
- 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;
複製代碼 |