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

TOP

返回列表