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

  151.         s++;
  152.       goto re;
  153.       end:
  154.    
  155.     system("pause");
  156.     return 0;
  157. }
複製代碼

TOP

返回列表