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

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

TOP

返回列表