返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     int x,y,z,sum=0;
  8.     int money,money2,h;
  9.     int a[]{0,0,0,0};
  10.     string b[]{"◆","★","▲","●"};
  11.     re2:
  12.     system("cls");
  13.     cout<<"賽馬場"<<endl;
  14.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  15.     cout<<"◆"<<endl;
  16.     cout<<"★"<<endl;
  17.     cout<<"▲"<<endl;
  18.     cout<<"●"<<endl;
  19.     cout<<endl;
  20.     cout<<"可用餘額:"<<sum<<"元"<<endl<<endl;
  21.     cout<<"(1)買入 (2)下注 (3)離開   請選擇:";
  22.     cin>>z;
  23.     if(z==1)
  24.     {

  25.         cout<<endl;
  26.         cout<<"買入: ";
  27.         cin>>money;
  28.         sum+=money;
  29.         goto re2;
  30.     }
  31.     else if(z==2&&sum>0)
  32.     {
  33.         cout<<endl;
  34.         cout<<"下注: ";
  35.         cin>>money2;
  36.         if(sum>=money2)
  37.         {
  38.             cout<<endl;
  39.             sum-=money2;
  40.             cout<<"下注幾號 <1>◆ <2>★ <3>▲ <4>● :";
  41.             cin>>h;
  42.             cout<<endl;
  43.             cout<<"比賽即將開始...";
  44.         }
  45.         else if(sum<money2)
  46.         {
  47.             cout<<"餘額不足請先買入"<<endl;
  48.             _sleep(1500);
  49.             goto re2;
  50.         }
  51.     }
  52.     else if(z==2&&sum<=0)
  53.     {
  54.         cout<<"餘額不足請先買入"<<endl;
  55.         _sleep(1500);
  56.         goto re2;
  57.     }
  58.     else if(z<=0||z>3)
  59.     {
  60.         cout<<"輸入錯誤 重新輸入";
  61.         _sleep(1500);
  62.         goto re2;
  63.     }
  64.     system("pause");
  65.     re:
  66.     if(a[0]<73&&a[1]<73&&a[2]<73&&a[3]<73)
  67.     {
  68.         system("cls");
  69.         cout<<"比賽開始"<<endl;
  70.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  71.         for(int i=0; i<=3; i++)
  72.        {
  73.            x=rand()%5+1;
  74.            a[i]+=x;
  75.            }
  76.            for(int i=1; i<=a[0]; i++)
  77.                 cout<<" ";
  78.             cout<<"◆"<<endl;
  79.            for(int i=1; i<=a[1]; i++)
  80.                 cout<<" ";
  81.             cout<<"★"<<endl;
  82.            for(int i=1; i<=a[2]; i++)
  83.                 cout<<" ";
  84.             cout<<"▲"<<endl;
  85.            for(int i=1; i<=a[3]; i++)
  86.                 cout<<" ";
  87.             cout<<"●"<<endl;
  88.          _sleep(100);
  89.         goto re;

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

TOP

返回列表