- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- srand(time(NULL));
- int x;
- int a[]={0,0,0,0};
- cout<<"「好事成雙」賽馬場"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- cout<<"★"<<endl;
- cout<<"■"<<endl;
- cout<<"▼"<<endl;
- cout<<"●"<<endl;
- system("pause");
- system("cls");
- re:
- if(a[1]<73 && a[2]<73 && a[3]<73 && a[4]<73)
- {
- system("cls");
- cout<<"比賽進行中"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=1; i<=4; i++)
- {
- x=rand()%4;
- a[i]+=x;
- }
- for(int i=1; i<=a[1]; i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=1; i<=a[2]; i++)
- cout<<" ";
- cout<<"■"<<endl;
- for(int i=1; i<=a[3]; i++)
- cout<<" ";
- cout<<"▼"<<endl;
- for(int i=1; i<=a[4]; i++)
- cout<<" ";
- cout<<"●"<<endl;
- _sleep(25);
- goto re;
- }
- else
- {
- system("cls");
- cout<<"比賽結束"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- }
- for(int i=1; i<=a[1]; i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=1; i<=a[2]; i++)
- cout<<" ";
- cout<<"■"<<endl;
- for(int i=1; i<=a[3]; i++)
- cout<<" ";
- cout<<"▼"<<endl;
- for(int i=1; i<=a[4]; i++)
- cout<<" ";
- cout<<"●"<<endl;
- system("pause");
- return 0;
- }
複製代碼 |