返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int t=1, balance=0, money, winner;
  7.     re1:
  8.     int a=0, b=0, c=0, d=0, r, option, buyin, bet, win;
  9.     system("cls");
  10.     cout<<"﹩財源滾滾賽馬場 ﹩";
  11.     cout<<" 第"<<t<<"局"<<endl;
  12.     cout<<"=========================================================================| 終點"<<endl;
  13.     cout<<"◢1◤"<<endl;
  14.     cout<<"◢2◤"<<endl;
  15.     cout<<"◢3◤"<<endl;
  16.     cout<<"◢4◤"<<endl;
  17.     cout<<"可用餘額: "<<balance<<"元"<<endl<<endl;
  18.     cout<<"(1)買入  (2)下注  (3)離開  請選擇: ";
  19.     cin>>option;
  20.     if(option==1)
  21.     {
  22.         cout<<"買入: ";
  23.         cin>>buyin;
  24.         balance+=buyin;   
  25.         goto re1;
  26.     }else if(option==2)
  27.     {
  28.         if(balance==0)
  29.         {
  30.             cout<<"可用餘額不足! 請先買入!"<<endl<<endl;
  31.             system("pause");
  32.             goto re1;
  33.         }
  34.         cout<<"請下注: ";
  35.         cin>>bet;
  36.         if(bet>balance)
  37.         {
  38.             cout<<"可用餘額不足! 請先買入!"<<endl<<endl;
  39.             system("pause");
  40.             goto re1;   
  41.         }else
  42.         {
  43.             cout<<endl<<"(1)◢1◤ (2)◢2◤  (3)◢3◤  (4)◢4◤   請選擇: ";
  44.             cin>>option;
  45.             cout<<"比賽即將開始..."<<endl<<endl;
  46.         }  
  47.     }else if(option==3)
  48.     {
  49.         goto end;  
  50.     }else
  51.     {
  52.         cout<<"輸入錯誤!"<<endl;
  53.         system("pause");
  54.         goto re1;
  55.     }
  56.     system("pause");
  57.     system("cls");
  58.     srand(time(NULL));
  59.     while(a!=75 && b!=75 && c!=75 && d!=75)
  60.     {
  61.         r=rand()%4;   
  62.         if(r==0)
  63.             a++;
  64.         else if(r==1)
  65.             b++;
  66.         else if(r==2)
  67.             c++;
  68.         else
  69.             d++;
  70.         cout<<"比賽進行中"<<endl;
  71.         cout<<"=========================================================================| 終點"<<endl;
  72.         for(int i=1; i<=a; i++)
  73.             cout<<" ";
  74.         cout<<"◢1◤"<<endl;
  75.         for(int i=1; i<=b; i++)
  76.             cout<<" ";
  77.         cout<<"◢2◤"<<endl;
  78.         for(int i=1; i<=c; i++)
  79.             cout<<" ";
  80.         cout<<"◢3◤"<<endl;
  81.         for(int i=1; i<=d; i++)
  82.             cout<<" ";
  83.         cout<<"◢4◤"<<endl;   
  84.         system("cls");      
  85.     }
  86.     cout<<"比賽結束";
  87.     if(a==75)
  88.     {
  89.         cout<<" 由◢1◤獲得勝利"<<endl;
  90.         winner=1;
  91.     }else if(b==75)
  92.     {   
  93.         cout<<" 由◢2◤獲得勝利"<<endl;   
  94.         winner=2;              
  95.     }else if(c==75)
  96.     {   
  97.         cout<<" 由◢3◤獲得勝利"<<endl;   
  98.         winner=3;              
  99.     }else
  100.     {   
  101.          cout<<" 由◢4◤獲得勝利"<<endl;                       
  102.          winner=4;                  
  103.     }
  104.     cout<<"------------------------------------------------------------------------| 終點"<<endl;  
  105.     for(int i=1; i<=a; i++)
  106.         cout<<" ";
  107.     cout<<"◢1◤"<<endl<<endl;
  108.     for(int i=1; i<=b; i++)
  109.         cout<<" ";
  110.     cout<<"◢2◤"<<endl<<endl;
  111.     for(int i=1; i<=c; i++)
  112.         cout<<" ";
  113.     cout<<"◢3◤"<<endl<<endl;
  114.     for(int i=1; i<=d; i++)
  115.         cout<<" ";
  116.     cout<<"◢4◤"<<endl<<endl;
  117.     t++;
  118.     if(win==option)
  119.     {
  120.         balance=balance+bet*3;
  121.         cout<<"獲得"<<bet*3<<"元"<<endl<<endl;
  122.         system("pause");
  123.         money+=bet*3;  
  124.     }else
  125.     {
  126.         balance=balance-bet;
  127.         cout<<"損失"<<bet<<"元"<<endl<<endl;
  128.         system("pause");
  129.         money-=bet;
  130.     }
  131.     goto re1;
  132.     end:
  133.     if(money==0)
  134.     {
  135.         cout<<"沒輸沒贏! 全身而退!"<<endl;              
  136.     }else if(money>=0)
  137.     {
  138.         cout<<"恭喜你! 這次總共贏了"<<money<<"元!"<<endl<<endl;                 
  139.     }else
  140.     {
  141.         cout<<"不好意思! 讓你損失了"<<-money<<"元!"<<endl<<endl;                           
  142.     }   
  143.     cout<<"謝謝光臨! 下次再來!"<<endl<<endl;      
  144.     system("pause");
  145.     return 0;   
  146. }
複製代碼

TOP

返回列表