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

TOP

返回列表