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

TOP

返回列表