返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<time.h>
  4. using namespace std;
  5. int main()
  6. {
  7.     while(true)
  8.     {
  9.         int horse1=0, horse2=0, horse3=0, horse4=0,random=0;
  10.         srand(time(NULL));
  11.         system("cls");
  12.         cout<<"「好事成雙」賽馬場"<<endl;
  13.         cout<<"------------------------------------------------------------------------| 終點"<<endl;
  14.         cout<<"◆"<<endl;
  15.         cout<<"★"<<endl;
  16.         cout<<"▲"<<endl;
  17.         cout<<"●"<<endl;
  18.         system("pause");
  19.         system("cls");
  20.         while(horse1!=75 && horse2!=75 && horse3!=75 && horse4!=75)
  21.         {
  22.             random=rand()%4;   //產生0~3之隨機亂數
  23.             if(random==0)
  24.             {
  25.                 horse1++;
  26.             }
  27.             else if(random==1)
  28.             {
  29.                 horse2++;
  30.             }
  31.             else if(random==2)
  32.             {
  33.                 horse3++;
  34.             }
  35.             else if(random==3)
  36.             {
  37.                 horse4++;
  38.             }
  39.             cout<<"比賽進行中"<<endl;
  40.             cout<<"------------------------------------------------------------------------| 終點"<<endl;
  41.             for(int i=1; i<=horse1; i++)
  42.             {
  43.                 cout<<" ";
  44.             }
  45.             cout<<"◆"<<endl;
  46.             for(int i=1; i<=horse2; i++)
  47.             {
  48.                 cout<<" ";
  49.             }
  50.             cout<<"★"<<endl;
  51.             for(int i=1; i<=horse3; i++)
  52.             {
  53.                 cout<<" ";
  54.             }
  55.             cout<<"▲"<<endl;
  56.             for(int i=1; i<=horse4; i++)
  57.             {
  58.                 cout<<" ";
  59.             }
  60.             cout<<"●"<<endl;
  61.             system("cls");      
  62.         }
  63.     }
  64.     system("pause");
  65.     return 0;   
  66. }
複製代碼

TOP

返回列表