返回列表 發帖
  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;
  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.       
  96.       cout<<"比賽結束!";
  97.    
  98.       
  99.        cout<<"賽馬結束!";
  100.      if(a==70)
  101.      {
  102.         cout<<"由◆先馳得點!"<<endl;
  103.      }else if(b==70)
  104.      {
  105.         cout<<"由★先馳得點!"<<endl;
  106.      }else if(c==70)
  107.      {
  108.         cout<<"由▲先馳得點!"<<endl;
  109.      }else
  110.      {
  111.         cout<<"由●先馳得點!"<<endl;
  112.      }
  113.      cout<<"------------------------------------------------------------------------| 終點"<<endl;      
  114.      for(int i=0;i<=a;i++)
  115.      {
  116.               cout<<" ";
  117.      }
  118.      cout<<"◆"<<endl;
  119.      for(int i=0;i<=b;i++)
  120.      {
  121.              cout<<" ";
  122.      }
  123.      cout<<"★"<<endl;
  124.      for(int i=0;i<=c;i++)
  125.      {
  126.              cout<<" ";
  127.      }
  128.      cout<<"▲"<<endl;
  129.      for(int i=0;i<=d;i++)
  130.      {
  131.              cout<<" ";
  132.      }
  133.      cout<<"●"<<endl;
  134.      
  135.       system("pause");

  136.         s++;
  137.       goto re;
  138.       end:
  139.    
  140.     system("pause");
  141.     return 0;
  142. }
複製代碼

TOP

返回列表