- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- srand(time(NULL));
- cout<<"賽馬場"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- int a[]{0,0,0,0};
- int s;
- cout<<"◆"<<endl;
- cout<<"★"<<endl;
- cout<<"▲"<<endl;
- cout<<"●"<<endl;
- system("pause");
- cout<<"比賽開始"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- re:
- if(a[0]<73&&a[1]<73&&a[2]<73&&a[3]<73){
- system("cls");
- cout<<"比賽進行中"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- s=rand()%4;
- a[s]++;
- for(int i=1; i<=a[0]; i++)
- cout<<" ";
- 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;
- _sleep(10);
- goto re;
- }else{
- system("cls");
- cout<<"比賽結束"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- }
- for(int i=1; i<=a[0]; i++)
- cout<<" ";
- 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;
- system("pause");
- return 0;
- }
複製代碼 |