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

TOP

返回列表