返回列表 發帖
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     int s[4]= {0,0,0,0};
  6.     string p[4]= {"1","2","3","4"};

  7.     srand(time(NULL));
  8.     cout<<"「好事成雙」賽馬場 第1局\n";
  9.     cout<<"------------------------|終點\n";
  10.     int r;
  11.     for(int i=0; i<4; i++)
  12.     {
  13.         cout<<p[i]<<endl;
  14.     }
  15.     system("pause");
  16.     system("cls");
  17.     while(s[r]<=18)
  18.     {
  19.         r=rand()%4;
  20.         s[r]++;
  21.         cout<<"比賽進行中\n";
  22.         cout<<"--------------------|\n";
  23.         for(int a=0; a<4; a++)
  24.         {
  25.             for(int j=0; j<s[a]; j++)
  26.             {
  27.                 cout<<" ";
  28.             }
  29.             cout<<p[a]<<endl;
  30.         }
  31.         _sleep(50);
  32.         system("cls");
  33.     }
  34.     cout<<"比賽結束由,"<<p[r]<<"先馳得點\n";
  35.     cout<<"-------------------\n";
  36.     for(int a=0; a<4; a++)
  37.     {
  38.         for(int j=0; j<s[a]; j++)
  39.         {
  40.             cout<<" ";
  41.         }
  42.         cout<<p[a]<<endl;

  43.     }

  44.     return 0;
  45. }
複製代碼

TOP

返回列表