- #include<iostream>
- #include<cstdlib>
- #include<time.h>
- using namespace std;
- int main()
- {
- while(true)
- {
- int cat1=0, cat2=0, cat3=0, cat4=0, random=0;
- system("cls");
- cout<<"「好事成雙」賽馬場"<<endl;
- cout<<"------------------------------------------------------------------------| 終點"<<endl;
- cout<<"◆"<<endl;
- cout<<"★"<<endl;
- cout<<"▲"<<endl;
- cout<<"●"<<endl;
- system("pause");
- system("cls");
-
- while(cat1!=75 && cat2!=75 && cat3!=75 && cat4!=75)
- {
- random=rand()%4; //產生0~3之隨機亂數
- if(random==0)
- cat1++;
- else if(random==1)
- cat2++;
- else if(random==2)
- cat3++;
- else if(random==3)
- cat4++;
- cout<<"比賽進行中"<<endl;
- cout<<"------------------------------------------------------------------------| 終點"<<endl;
- for(int i=1; i<=cat1; i++)
- cout<<" ";
- cout<<"◆"<<endl;
- for(int i=1; i<=cat2; i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=1; i<=cat3; i++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int i=1; i<=cat4; i++)
- cout<<" ";
- cout<<"●"<<endl;
- system("cls");
- }
-
- }
- system("pause");
- return 0;
-
- }
複製代碼 |