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

TOP

返回列表