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

TOP

返回列表