- #include <iostream>
- #include <cstdlib>
- #include <time.h>
- using namespace std;
- int main()
- {
- int h1=0,h2=0,h3=0,h4=0;
- srand(time(NULL));
- int random=0;
- cout<<"「賽馬場」"<<endl;
- cout<<"|--------------------------------------------------------------------------|終點"<<endl;
- cout<<"0"<<endl;
- cout<<"1"<<endl;
- cout<<"2"<<endl;
- cout<<"3"<<endl;
- while(houres1!=75 && houres2!=75 && houres3!=75 && houres4!=75)
- { random=rand()%4;
- if(random==0)
- { houres1++;
- }
- else if(random==1)
- { houres2++;
- }
- else if(random==2)
- { houres3++;
- }
- else if(random==3)
- { houres4++;
- }
- cout<<"比賽開始"<<endl;
- cout<<"|----------------------------------------------------------------------------|終點"<<endl;
- for(int i=1; i<=h1; i++)
- {
- cout<<" ";
- }
- cout<<"2"<<endl;
- for(int i=1; i<=h2; i++)
- {
- cout<<" ";
- }
- cout<<"3"<<endl;
- for(int i=1; i<=h3; i++)
- {
- cout<<" ";
- }
- cout<<"4"<<endl;
- for(int i=1; i<=h4; i++)
- {
- cout<<" ";
- }
- cout<<"3"<<endl;
- system("cls");
-
- }
- system("pause");
- return 0;
- }
複製代碼 |