返回列表 發帖
本帖最後由 吳孟樵 於 2025-2-1 11:53 編輯
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     int r=0,n=1,speed=50;
  6. re:
  7.     system("cls");
  8.     int s[4]= {0,0,0,0};
  9.     srand(time(NULL));
  10.     cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
  11.     cout<<"------------------------------------------------------|終點"<<endl;
  12.     string p[4]= {"◆","★","▲","●"};
  13.     for(int i=0; i<=3; i++)
  14.     {
  15.         cout<<p[i]<<endl;
  16.     }
  17.     system("pause");
  18.     system("cls");
  19.     while(s[r]<=52)
  20.     {
  21.         r=rand()%4;
  22.         s[r]++;
  23.         cout<<"比賽進行中"<<endl;
  24.         cout<<"------------------------------------------------------|終點"<<endl;
  25.         for(int i=0; i<=3; i++)
  26.         {
  27.             for(int j=0; j<=s[i]; j++)
  28.             {
  29.                 cout<<" ";
  30.             }
  31.             cout<<p[i]<<endl;

  32.         }
  33.         _sleep(speed);
  34.         system("cls");
  35.     }
  36.     cout<<"比賽結束! 由"<<p[r]<<"先馳得點!"<<endl;
  37.     cout<<"------------------------------------------------------|終點"<<endl;
  38.     for(int i=0; i<=3; i++)
  39.     {
  40.         for(int j=0; j<=s[i]; j++)
  41.         {
  42.             cout<<" ";
  43.         }
  44.         cout<<p[i]<<endl;
  45.     }
  46.     system("pause");
  47.     n++;
  48.     goto re;
  49.     return 0;
  50. }
複製代碼

TOP

返回列表