返回列表 發帖
0000000000000000000000000000000

TOP

本帖最後由 啓銓 於 2018-6-4 20:29 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     srand(time(NULL));
  7.     int x=1,balance=0,option,buyin,bet,player,wallet=0;
  8.     re:
  9.     system("cls");
  10.     string n[]={"馬","馬英九","馬友友","歐巴馬"};
  11.     int s[]={0,0,0,0};
  12.     int r;
  13.     cout<<"「射後不理」賭馬場 第"<<x<<"局"<<endl;
  14.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  15.     for(int i=0; i<4; i++)
  16.         cout<<n[i]<<endl;
  17.     cout<<endl<<"你剩的錢: "<<balance<<"元"<<endl<<endl;   
  18.     cout<<"(1)買 (2)下注 (3)滾蛋 選擇: ";
  19.     cin>>option;
  20.     if(option==1)
  21.     {
  22.         cout<<"買: ";
  23.         cin>>buyin;
  24.         if(buyin<=0)
  25.         {
  26.             cout<<"白癡連這都不會!"<<endl;
  27.             _sleep(1500);
  28.             goto re;
  29.         }
  30.         balance+=buyin;
  31.         goto re;            
  32.     }else if(option==2)
  33.     {
  34.         cout<<"下注: ";
  35.         cin>>bet;
  36.         if(bet<=0)
  37.         {
  38.             cout<<"媽的你博罕嗎?"<<endl;
  39.             _sleep(1500);
  40.             goto re;
  41.         }
  42.         if(bet>balance)
  43.         {
  44.             cout<<"你先去夜市當乞丐"<<endl;
  45.             _sleep(1500);
  46.             goto re;            
  47.         }
  48.         cout<<endl<<"(1)馬 (2)馬英九 (3)馬友友 (4)歐巴馬  請選擇: ";
  49.         cin>>player;
  50.         cout<<"比賽即將開始..."<<endl<<endl;
  51.     }else if(option==3)
  52.     {
  53.         goto end;  
  54.     }else
  55.     {
  56.         cout<<"拜託你先去看醫生!"<<endl;
  57.         _sleep(1500);
  58.         goto re;     
  59.     }
  60.     system("pause");
  61.     while(true)
  62.     {
  63.         cout<<"比賽進行中"<<endl;
  64.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  65.         r=rand()%4;   //0~3
  66.         s[r]++;
  67.         for(int i=0; i<4; i++)
  68.         {
  69.             for(int j=0; j<s[i]; j++)
  70.                 cout<<" ";
  71.             cout<<n[i]<<endl;     
  72.         }
  73.         _sleep(10);
  74.         system("cls");
  75.         if(s[r]==76)
  76.             break;
  77.     }
  78.     cout<<"比賽結果! 由 "<<n[r]<<" 先馳得點!"<<endl;
  79.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  80.     for(int i=0; i<4; i++)
  81.     {
  82.         for(int j=0; j<s[i]; j++)
  83.             cout<<" ";
  84.         cout<<n[i]<<endl;
  85.     }
  86.     if(player-1==r)
  87.     {
  88.         cout<<"贏了 "<<bet*3<<"元!";
  89.         balance+=bet*3;
  90.         wallet+=bet*3;              
  91.     }else
  92.     {
  93.         cout<<"損失 "<<bet<<"元";
  94.         balance-=bet;
  95.         wallet-=bet;
  96.     }
  97.     cout<<endl<<endl;
  98.     system("pause");
  99.     x++;
  100.     goto re;
  101.     end:
  102.     cout<<endl;
  103.     if(wallet==0)
  104.         cout<<"沒輸沒贏! 不要再賭了!"<<endl<<endl;
  105.     else if(wallet>0)
  106.         cout<<"恭喜你! 贏了"<<wallet<<"元!"<<endl<<endl;
  107.     else
  108.         cout<<"你是豬哥亮嗎?"<<-wallet<<"元!"<<endl<<endl;
  109.     cout<<"謝謝光臨! 下次再來!"<<endl<<endl;
  110.     system("pause");
  111.     return 0;
複製代碼

TOP

返回列表