返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.    
  7.     int money=0,cg,n=1,buy,bet,player,choose;
  8.     choose:
  9.     cout<<"第"<<n<<"場"<<endl;      
  10.     cout<<"$ 財源滾滾賽馬場 $"<<endl;
  11.     cout<<endl<<"-----------------------------------------------------------------------|終點|"<<endl;
  12.     cout<<"◢1◤"<<endl;
  13.     cout<<"◢2◤"<<endl;
  14.     cout<<"◢3◤"<<endl;
  15.     cout<<"◢4◤"<<endl;
  16.     cout<<"您有"<<money<<"元"<<endl;
  17.     cout<<"需先買入並下注"<<endl;
  18.     cout<<"(1)買入(2)賭(3)離開"<<endl;
  19.     cin>>choose;
  20.     if(choose==1)
  21.     {
  22.         cout<<"要買多少?"<<endl;
  23.         cin>>buy;
  24.         money=money+buy;
  25.         system("cls");
  26.         goto choose;            
  27.     }else if(choose==2)
  28.     {
  29.         cout<<"要賭哪位選手?(共有4位)"<<endl;
  30.         cin>>player;
  31.         if(player>4 || player<1)
  32.         {
  33.             system("cls");
  34.             goto choose;         
  35.         }
  36.         cout<<"要賭多少?"<<endl;
  37.         cin>>bet;
  38.         if(bet>money)
  39.         {
  40.             system("cls");
  41.             goto choose;         
  42.         }
  43.         cout<<"(1)比賽開始(2)重選"<<endl;
  44.         cin>>cg;
  45.         system("cls");
  46.         if(cg==1)
  47.         goto re;
  48.         else if(cg==2)
  49.         goto choose;
  50.         else
  51.         cout<<"輸入錯誤"<<endl;
  52.         goto choose;      
  53.     }else if(choose==3)
  54.     {
  55.         system("cls");
  56.     }   
  57.     else
  58.     cout<<"輸入錯誤"<<endl;
  59.     system("cls");
  60.     goto choose;
  61.     re:
  62.     cout<<"$ 財源滾滾賽馬場 $"<<endl<<endl;
  63.     cout<<endl<<"-----------------------------------------------------------------------|終點|"<<endl;
  64.     cout<<"◢1◤"<<endl;
  65.     cout<<"◢2◤"<<endl;
  66.     cout<<"◢3◤"<<endl;
  67.     cout<<"◢4◤"<<endl;
  68.     system("pause");
  69.     system("cls");
  70.     srand(time(NULL));
  71.     int a=0 ,b=0, c=0, d=0,r,bigger,biggest,more;
  72.     while((a!=65) && (b!=65) && (c!=65) && (d!=65))
  73.     {
  74.         r=rand()%4;
  75.         if(r==0)              
  76.         a++;
  77.         else if(r==1)              
  78.         b++;
  79.         else if(r==2)              
  80.         c++;
  81.         else if(r==3)              
  82.         d++;
  83.     cout<<"比賽進行中"<<endl<<endl;
  84.     cout<<endl<<"-----------------------------------------------------------------|終點|"<<endl;
  85.     for(int i=1;i<=a;i++)
  86.         cout<<" ";
  87.     cout<<"◢1◤"<<endl;
  88.     for(int i=1;i<=b;i++)
  89.         cout<<" ";
  90.     cout<<"◢2◤"<<endl;
  91.     for(int i=1;i<=c;i++)
  92.         cout<<" ";
  93.     cout<<"◢3◤"<<endl;
  94.     for(int i=1;i<=d;i++)
  95.         cout<<" ";
  96.     cout<<"◢4◤"<<endl;
  97.     system("cls");         
  98.     }
  99.     more=(a>b)?a:b;
  100.     bigger=(c>d)?c:d;
  101.     biggest=(bigger>more)?bigger:more;
  102.     if(biggest==a)
  103.         cout<<"1號勝利"<<endl;
  104.     else if(biggest==b)
  105.              cout<<"2號勝利"<<endl;
  106.     else if(biggest==c)
  107.              cout<<"3號勝利"<<endl;
  108.     else if(biggest==d)
  109.     cout<<"4號勝利"<<endl;
  110.     cout<<"第"<<n<<"場"<<endl;
  111.     cout<<endl<<"-----------------------------------------------------------------|終點|"<<endl;
  112.     for(int i=1;i<=a;i++)
  113.         cout<<" ";
  114.     cout<<"◢1◤"<<endl;
  115.     for(int i=1;i<=b;i++)
  116.         cout<<" ";
  117.     cout<<"◢2◤"<<endl;
  118.     for(int i=1;i<=c;i++)
  119.         cout<<" ";
  120.     cout<<"◢3◤"<<endl;
  121.     for(int i=1;i<=d;i++)
  122.         cout<<" ";
  123.     cout<<"◢4◤"<<endl;
  124.     n++;
  125.     if(biggest==a && player==1)
  126.     {
  127.         money=money+bet;
  128.         cout<<"恭喜你贏了"<<bet<<"元"<<endl;              
  129.     }else if(biggest==b && player==2)
  130.     {
  131.         money=money+bet;
  132.         cout<<"恭喜你贏了"<<bet<<"元"<<endl;              
  133.     }else if(biggest==c && player==3)
  134.     {
  135.         money==money+bet;
  136.         cout<<"恭喜你贏了"<<bet<<"元"<<endl;              
  137.     }else if(biggest==d && player==4)
  138.     {
  139.         money=money+bet;
  140.         cout<<"恭喜你贏了"<<bet<<"元"<<endl;              
  141.     }else
  142.     {
  143.         money=money-bet;
  144.         cout<<"恭喜你輸了"<<bet<<"元"<<endl;     
  145.     }
  146.     system("pause");
  147.     system("cls");
  148.     goto choose;
  149.     system("pause");   
  150.     return 0;
  151. }
複製代碼

TOP

返回列表