返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     int n =1,blance=0;
  8.     re:   
  9.     system("cls");
  10.     int a=0,b=0,c=0,d=0,r, option, buyin =0,bet,horse ;
  11.    

  12.     string words ="賽馬進行中";
  13.    
  14.     string name[4] = {"◆","★","▲","●"};
  15.    
  16.   
  17.     int position =0;
  18.     cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
  19.     cout<<"------------------------------------------------------------------------| 終點"<<endl;
  20.     cout<<"◆"<<endl;
  21.     cout<<"★"<<endl;
  22.     cout<<"▲"<<endl;
  23.     cout<<"●"<<endl;
  24.     cout<<endl;
  25.     cout<<"可用餘額:"<<blance<<"元"<<endl;
  26.     cout<<endl;
  27.     cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
  28.     cin>>option;
  29.   
  30.     if(option==1)
  31.     {
  32.         cout<<"買入:";
  33.         cin>>buyin;
  34.         blance += buyin;
  35.         goto re;
  36.     }else if(option==2)
  37.     {
  38.         cout<<"請下注:";
  39.         cin>>bet;
  40.         if(bet > blance)
  41.         {
  42.            cout<<"您餘額不足,請重新下注!"<<endl;            
  43.            system("pause");
  44.            goto re;
  45.         }else if(bet >0 && bet<=blance)
  46.         {
  47.            cout<<"(1)◆ (2)★ (3)▲(4)●請選擇:";
  48.            cin>>horse;
  49.            blance -= bet;
  50.            cout<<"即將開始賽馬!"<<endl;
  51.         }else
  52.         {
  53.            cout<<"您輸入錯誤,請重新下注!"<<endl;            
  54.            system("pause");
  55.            goto re;
  56.         }
  57.         
  58.     }else
  59.     {
  60.          
  61.         goto end;
  62.     }
  63.    
  64.     system("pause");
  65.     system("cls");
  66.     srand(time(NULL));
  67.   
  68.     while(a<=70 && b<=70 && c<=70 && d<=70)
  69.     {  
  70.       cout<<words<<endl;
  71.       cout<<"------------------------------------------------------------------------| 終點"<<endl;   
  72.    
  73.       r = rand()%4+1;

  74.       switch(r)
  75.       {
  76.           case 1:
  77.                a++;
  78.                break;
  79.           case 2:
  80.                b++;
  81.                break;
  82.           case 3:
  83.                c++;
  84.                break;
  85.           case 4:
  86.                d++;
  87.                break;
  88.       }
  89.       
  90.       
  91.       for(int i=0;i<=a;i++)
  92.       {
  93.           cout<<" ";
  94.       }
  95.       cout<<name[0]<<endl;
  96.       
  97.      
  98.       for(int i=0;i<=b;i++)
  99.       {
  100.           cout<<" ";
  101.       }
  102.       cout<<name[1]<<endl;
  103.       
  104.    
  105.       for(int i=0;i<=c;i++)
  106.       {
  107.           cout<<" ";
  108.       }
  109.       cout<<name[2]<<endl;
  110.       
  111.      
  112.       for(int i=0;i<=d;i++)
  113.       {
  114.           cout<<" ";
  115.       }
  116.       cout<<name[3]<<endl;
  117.       
  118.    
  119.       if(a==70 || b==70 || c==70 || d==70)
  120.       {  
  121.          if(a==70)
  122.               position = 0;
  123.          if(b==70)
  124.               position =1;
  125.          if(c==70)
  126.               position =2;
  127.          if(d==70)
  128.               position =3;           
  129.          
  130.          words = "比賽結束!由"+name[position]+"先馳得點!";
  131.       }
  132.       
  133.       if(a==71 || b==71 || c==71 || d==71)
  134.       {               
  135.       }else{      
  136.         system("cls");
  137.       }
  138.       
  139.     }
  140.    
  141.     n++;
  142.     system("pause");
  143.     goto re;     
  144.     end:
  145.     system("pause");  
  146.     return 0;   
  147. }
複製代碼

TOP

返回列表