返回列表 發帖
本帖最後由 邱品惟 於 2023-8-15 20:01 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int monny=0,choose,x,y,m,r,d;
  7.     int round=1;
  8.     re:
  9.     int s[]={0,0,0,0};
  10.     string p[]={"◆","★","▲","●"};
  11.     srand(time(NULL));
  12.     cout<<"「好事成雙」賽馬場第"<<round<<"場"<<endl;
  13.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  14.     for(int i=0; i<4; i++)
  15.         cout<<p[i]<<endl;
  16.     cout<<endl;
  17.     cout<<"可用餘額:"<<monny<<endl<<endl;
  18.     cout<<"(1)買入 (2)下注 (3)離開 (4)開始賽馬"<<endl;
  19.     cin>>choose;
  20.     if(choose==1)
  21.     {
  22.         cout<<"儲值";
  23.         cin>>m;
  24.         monny=m+monny;
  25.         system("cls");
  26.         goto re;
  27.     }
  28.     else if(choose==2)
  29.     {
  30.         cout<<"(1)◆ (2)★ (3)▲ (4)●"<<endl;
  31.         cin>>y;
  32.         if(y<=4&&y>=1)
  33.         {
  34.             cout<<"下注"<<endl;
  35.             cin>>x;
  36.             if(monny>=x)
  37.             {
  38.                 monny=monny-x;
  39.                 system("cls");
  40.             }
  41.             else if(x>monny)
  42.             {
  43.                 cout<<"你還不夠"<<x-monny<<"元"<<endl;
  44.                 system("pause");
  45.                 system("cls");
  46.             }
  47.             goto re;
  48.         }
  49.         else
  50.         {
  51.             cout<<"輸入錯誤"<<endl;
  52.             system("pause");
  53.             system("cls");
  54.             goto re;
  55.         }  
  56.         
  57.             
  58.     }
  59.     else if(choose==3)
  60.     {
  61.         goto bye;
  62.     }
  63.     else if(choose==4)
  64.     {
  65.          if(x==0)
  66.          {
  67.              cout<<"你真的不賭?";
  68.              cout<<"(1)賭 (2)不賭";
  69.              cin>>d;
  70.              if(d==1)
  71.              {
  72.                  system("cls");
  73.                  goto re;
  74.              }   
  75.              if(d==2)
  76.              {
  77.                  goto see;
  78.              }
  79.          }   
  80.     }
  81.     else
  82.     {
  83.         cout<<"輸入錯誤"<<endl;
  84.         system("pause");
  85.         system("cls");
  86.         goto re;
  87.     }
  88.     see:
  89.     system("pause");
  90.     while(true)
  91.     {
  92.         system("cls");
  93.         r=rand()%4;   
  94.         s[r]++;      
  95.         cout<<"比賽進行中"<<endl;
  96.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  97.         for(int i=0; i<=s[0]; i++)
  98.             cout<<" ";
  99.         cout<<"◆"<<endl;
  100.         for(int i=0; i<=s[1]; i++)
  101.             cout<<" ";
  102.         cout<<"★"<<endl;
  103.         for(int i=0; i<=s[2]; i++)
  104.             cout<<" ";
  105.         cout<<"▲"<<endl;
  106.         for(int i=0; i<=s[3]; i++)
  107.             cout<<" ";
  108.         cout<<"●"<<endl;
  109.         if(s[r]==73)
  110.             break;
  111.                      
  112.     }
  113.     system("cls");
  114.     cout<<"比賽結束"<<endl;
  115.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  116.     for(int i=0; i<=s[0]; i++)
  117.         cout<<" ";
  118.     cout<<"◆"<<endl;
  119.     for(int i=0; i<=s[1]; i++)
  120.         cout<<" ";
  121.     cout<<"★"<<endl;
  122.     for(int i=0; i<=s[2]; i++)
  123.         cout<<" ";
  124.     cout<<"▲"<<endl;
  125.     for(int i=0; i<=s[3]; i++)
  126.         cout<<" ";
  127.     cout<<"●"<<endl;
  128.     round=round+1;
  129.     cout<<"恭喜"<<p[r]<<"獲勝"<<endl;
  130.     if(y-1==r)
  131.     {
  132.         cout<<"恭喜你押對了,得到了雙倍"<<endl;
  133.         monny=monny+x*2;
  134.     }
  135.     else
  136.         cout<<"謝謝你的錢,我會拿去吃好料的"<<endl;
  137.     system("pause");
  138.     system("cls");
  139.     x=0;
  140.     goto re;
  141.     bye:
  142.     if(monny+x>0)
  143.     {
  144.         cout<<"還你"<<monny+x<<"元"<<endl;
  145.     }
  146.     system("pause");
  147.     return 0;
  148. }
複製代碼

TOP

返回列表