返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     int x,y,z,sum=0,money,money2,h,t=1,e=0;
  8.     string b[]{"◆","★","▲","●"};
  9.     re2:
  10.     int a[]{0,0,0,0};
  11.     system("cls");
  12.     cout<<"空蕩蕩賽馬場  第"<<t<<"局"<<endl;
  13.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  14.     cout<<"◆"<<endl;
  15.     cout<<"★"<<endl;
  16.     cout<<"▲"<<endl;
  17.     cout<<"●"<<endl;
  18.     cout<<endl;
  19.     cout<<"可用餘額:"<<sum<<"元"<<endl<<endl;
  20.     cout<<"<1>買入 <2>下注 <3>離開   請選擇:";
  21.     cin>>z;
  22.     if(z==1)
  23.     {
  24.         cout<<endl;
  25.         cout<<"買入: ";
  26.         cin>>money;
  27.         sum+=money;
  28.         goto re2;
  29.     }
  30.     else if(z==2&&sum>0)
  31.     {
  32.         cout<<endl;
  33.         cout<<"下注: ";
  34.         cin>>money2;
  35.         if(sum>=money2)
  36.         {
  37.             cout<<endl;
  38.             sum-=money2;
  39.             re3:
  40.             cout<<"下注幾號 <1>◆ <2>★ <3>▲ <4>● :";
  41.             cin>>h;
  42.             cout<<endl;
  43.             if(h>4||h<1)
  44.             {
  45.                 cout<<"輸入錯誤 重新輸入"<<endl<<endl;
  46.                 _sleep(1500);
  47.                 goto re3;
  48.             }
  49.         }
  50.         else if(sum<money2)
  51.         {
  52.             cout<<"餘額不足請先買入"<<endl;
  53.             _sleep(1500);
  54.             goto re2;
  55.         }
  56.     }
  57.     else if(z==2&&sum<=0)
  58.     {
  59.         cout<<"餘額不足請先買入"<<endl;
  60.         _sleep(1500);
  61.         goto re2;
  62.     }
  63.     else if(z<=0||z>3)
  64.     {
  65.         cout<<"輸入錯誤 重新輸入";
  66.         _sleep(1500);
  67.         goto re2;
  68.     }
  69.     else if(z==3)
  70.     {
  71.         system("pause");
  72.         goto re4;
  73.     }
  74.     system("pause");
  75.     re:
  76.     if(a[0]<73&&a[1]<73&&a[2]<73&&a[3]<73)
  77.     {
  78.         system("cls");
  79.         cout<<"比賽開始"<<endl;
  80.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  81.         for(int i=0; i<=3; i++)
  82.        {
  83.            x=rand()%5+1;
  84.            a[i]+=x;
  85.            }
  86.            for(int i=1; i<=a[0]; i++)
  87.                 cout<<" ";
  88.             cout<<"◆"<<endl;
  89.            for(int i=1; i<=a[1]; i++)
  90.                 cout<<" ";
  91.             cout<<"★"<<endl;
  92.            for(int i=1; i<=a[2]; i++)
  93.                 cout<<" ";
  94.             cout<<"▲"<<endl;
  95.            for(int i=1; i<=a[3]; i++)
  96.                 cout<<" ";
  97.             cout<<"●"<<endl;
  98.          _sleep(100);
  99.         goto re;

  100.     }
  101.     else
  102.     {
  103.         if(a[0]>=73)
  104.             y=0;
  105.         if(a[1]>=73)
  106.             y=1;
  107.         if(a[2]>=73)
  108.             y=2;
  109.         if(a[3]>=73)
  110.             y=3;
  111.         system("cls");
  112.         cout<<"比賽結束由"<<b[y]<<"獲勝"<<endl;
  113.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  114.            for(int i=1; i<=a[0]; i++)
  115.                 cout<<" ";
  116.             cout<<"◆"<<endl;
  117.            for(int i=1; i<=a[1]; i++)
  118.                 cout<<" ";
  119.             cout<<"★"<<endl;
  120.            for(int i=1; i<=a[2]; i++)
  121.                 cout<<" ";
  122.             cout<<"▲"<<endl;
  123.            for(int i=1; i<=a[3]; i++)
  124.                 cout<<" ";
  125.             cout<<"●"<<endl;
  126.     }
  127.     if(y+1==h)
  128.     {
  129.         cout<<"賺到"<<money2*3<<"元"<<endl;
  130.         sum+=money2*4;
  131.         e+=money2*3;
  132.     }
  133.     if(y+1!=h)
  134.     {
  135.         cout<<"損失"<<money2<<"元"<<endl;
  136.         e-=money2;
  137.     }
  138.     system("pause");
  139.     t+=1;
  140.     goto re2;
  141.     re4:
  142.     if(e>0)
  143.     {
  144.         cout<<"恭喜你!這次總共贏了"<<e<<"元!"<<endl<<endl;
  145.         cout<<"謝謝光臨 下次還來"<<endl;
  146.     }
  147.     else if(e<0)
  148.     {
  149.         cout<<"不好意思!讓你損失了"<<-e<<"元!"<<endl<<endl;
  150.         cout<<"謝謝光臨 下次還來"<<endl;
  151.     }
  152.     else
  153.     {
  154.         cout<<"沒輸沒贏!全身而退!"<<endl<<endl;
  155.         cout<<"謝謝光臨 下次還來"<<endl;
  156.     }
  157.     cout<<
  158.     system("pause");
  159.     return 0;
  160. }
複製代碼

TOP

返回列表