返回列表 發帖
  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;
  8.     int a[]{0,0,0,0};
  9.     string b[]{"◆","★","▲","●"};
  10.     re2:
  11.     system("cls");
  12.     cout<<"空蕩蕩賽馬場"<<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.             cout<<"下注幾號 <1>◆ <2>★ <3>▲ <4>● :";
  40.             cin>>h;
  41.             cout<<endl;
  42.             cout<<"比賽即將開始...";
  43.         }
  44.         else if(sum<money2)
  45.         {
  46.             cout<<"餘額不足請先買入"<<endl;
  47.             _sleep(1500);
  48.             goto re2;
  49.         }
  50.     }
  51.     else if(z==2&&sum<=0)
  52.     {
  53.         cout<<"餘額不足請先買入"<<endl;
  54.         _sleep(1500);
  55.         goto re2;
  56.     }
  57.     else if(z<=0||z>3)
  58.     {
  59.         cout<<"輸入錯誤 重新輸入";
  60.         _sleep(1500);
  61.         goto re2;
  62.     }
  63.     system("pause");
  64.     re:
  65.     if(a[0]<73&&a[1]<73&&a[2]<73&&a[3]<73)
  66.     {
  67.         system("cls");
  68.         cout<<"比賽開始"<<endl;
  69.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  70.         for(int i=0; i<=3; i++)
  71.        {
  72.            x=rand()%5+1;
  73.            a[i]+=x;
  74.            }
  75.            for(int i=1; i<=a[0]; i++)
  76.                 cout<<" ";
  77.             cout<<"◆"<<endl;
  78.            for(int i=1; i<=a[1]; i++)
  79.                 cout<<" ";
  80.             cout<<"★"<<endl;
  81.            for(int i=1; i<=a[2]; i++)
  82.                 cout<<" ";
  83.             cout<<"▲"<<endl;
  84.            for(int i=1; i<=a[3]; i++)
  85.                 cout<<" ";
  86.             cout<<"●"<<endl;
  87.          _sleep(100);
  88.         goto re;

  89.     }
  90.     else
  91.     {
  92.         if(a[0]>=73)
  93.             y=0;
  94.         if(a[1]>=73)
  95.             y=1;
  96.         if(a[2]>=73)
  97.             y=2;
  98.         if(a[3]>=73)
  99.             y=3;
  100.         system("cls");
  101.         cout<<"比賽結束由"<<b[y]<<"獲勝"<<endl;
  102.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  103.            for(int i=1; i<=a[0]; i++)
  104.                 cout<<" ";
  105.             cout<<"◆"<<endl;
  106.            for(int i=1; i<=a[1]; i++)
  107.                 cout<<" ";
  108.             cout<<"★"<<endl;
  109.            for(int i=1; i<=a[2]; i++)
  110.                 cout<<" ";
  111.             cout<<"▲"<<endl;
  112.            for(int i=1; i<=a[3]; i++)
  113.                 cout<<" ";
  114.             cout<<"●"<<endl;
  115.     }
  116.     system("pause");
  117.     return 0;
  118. }
複製代碼

TOP

返回列表