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

TOP

返回列表