返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int s=1,m=0,bg=0;
  7.     re:
  8.       
  9.     int a=0,b=0,c=0,d=0,r,o,z,h,w;
  10.     system("cls");
  11.     cout<<"賽馬場 第"<<s<<"局"<<endl;
  12.     cout<<"--------------------------------------------------------------------|終點"<<endl;
  13.    
  14.     cout<<"◆"<<endl;
  15.     cout<<"★"<<endl;
  16.     cout<<"▲"<<endl;
  17.     cout<<"●"<<endl;
  18.     cout<<"可用餘額: "<<m<<"元"<<endl<<endl;
  19.     cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
  20.     cin>>o;
  21.     if(o==1)
  22.     {
  23.             cout<<"買入: ";
  24.             cin>>z;
  25.             m=m+z;
  26.             goto re;
  27.     }else if(o==2)
  28.     {
  29.         cout<<"請下注: ";
  30.         cin>>z;
  31.         if(z > m)  
  32.         {
  33.             cout<<"餘額不足,請重新下注!"<<endl;
  34.             system("pause");
  35.             goto re;
  36.         }else if(z>=0 && z<= m)
  37.         {
  38.             cout<<"(1)◆馬 (2)★馬 (3)▲馬 (4)●馬 請選擇:";
  39.             cin>>h;
  40.             cout<<"比賽即將開始!"<<endl<<endl;   
  41.          }
  42.     }else if(o==3)
  43.     {
  44.         goto end;  
  45.     }
  46.         else
  47.         {
  48.             cout<<"您輸入錯誤!!請重新下注!"<<endl;
  49.             system("pause");
  50.             goto re;
  51.         }
  52.   
  53.             
  54.     system("pause");
  55.     system("cls");
  56.     srand(time(NULL));
  57.    
  58.     while(a!=70 && b!=70 && c!=70 && d!=70)
  59.       {
  60.      cout<<"起跑嘍~~~~~"<<endl;
  61.      cout<<"------------------------------------------------------------------------| 終點"<<endl;         
  62.      
  63.       r = rand()%4+1;   
  64.             if(r==1)
  65.                 a++;  
  66.             if(r==2)
  67.                 b++;  
  68.             if(r==3)
  69.                 c++;  
  70.             if(r==4)
  71.                 d++;
  72.                
  73.              for(int i=0;i<=a;i++)  
  74.              {
  75.                   cout<<" ";
  76.              }
  77.              cout<<"◆"<<endl;
  78.              for(int i=0;i<=b;i++)
  79.              {  
  80.                   cout<<" ";
  81.              }
  82.              cout<<"★"<<endl;
  83.             
  84.              for(int i=0;i<=c;i++)
  85.              {  
  86.                   cout<<" ";
  87.              }
  88.              cout<<"▲"<<endl;
  89.              for(int i=0;i<=d;i++)  
  90.              {     
  91.                    cout<<" ";
  92.              }
  93.              cout<<"●"<<endl;
  94.              system("cls");
  95.       }
  96.        cout<<"比賽結束! 由";
  97.        if(a==75)
  98.     {
  99.         cout<<"◆";
  100.         w = 1;
  101.     }
  102.     else if(b==75)
  103.     {
  104.         cout<<"★";
  105.         w = 2;
  106.     }
  107.     else if(c==75)
  108.     {
  109.         cout<<"▲";
  110.         w = 3;
  111.     }
  112.     else
  113.     {
  114.         cout<<"●";
  115.         w = 4;
  116.     }
  117.     cout<<"先馳得點"<<endl;
  118.       
  119.      cout<<"------------------------------------------------------------------------| 終點"<<endl;      
  120.      for(int i=0;i<=a;i++)
  121.      {
  122.               cout<<" ";
  123.      }
  124.      cout<<"◆"<<endl;
  125.      for(int i=0;i<=b;i++)
  126.      {
  127.              cout<<" ";
  128.      }
  129.      cout<<"★"<<endl;
  130.      for(int i=0;i<=c;i++)
  131.      {
  132.              cout<<" ";
  133.      }
  134.      cout<<"▲"<<endl;
  135.      for(int i=0;i<=d;i++)
  136.      {
  137.              cout<<" ";
  138.      }
  139.      cout<<"●"<<endl;
  140.      
  141.      if(h==w)
  142.      {
  143.              m=m+(z*3);
  144.              cout<<"贏了"<<z*3<<"元!"<<endl;
  145.              bg+=z*3;
  146.      }else
  147.      {
  148.           m=m-z;
  149.           cout<<"損失"<<z<<"元!"<<endl;
  150.           bg-=z;
  151.      }
  152.      
  153.       system("pause");

  154.         s++;
  155.       goto re;
  156.       end:
  157.          
  158.           if(bg==0)
  159.     {
  160.         cout<<"沒輸沒贏!"<<endl;
  161.     }else if(bg>0)
  162.     {
  163.         cout<<"恭喜你! 這次總共贏了"<<bg<<"元!"<<endl;  
  164.     }else
  165.     {
  166.         cout<<"哈哈 你損失了"<<-bg<<"元!"<<endl;  
  167.     }
  168.     cout<<"銘謝惠顧! 下次再來!"<<endl;   
  169.    
  170.     system("pause");
  171.     return 0;
  172. }
複製代碼

TOP

返回列表