- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- srand(time(NULL));
- int d[]={0,0,0,0},speed=30;
- cout<<"「好事成雙」賽馬場"<<endl;
- cout<<"-----------------------------------------------------------------| 終點"<<endl;
- cout<<"●"<<endl;
- cout<<"▲"<<endl;
- cout<<"★"<<endl;
- cout<<"◆"<<endl;
- system("pause");
- while(true)
- {
- system("cls");
- cout<<"比賽進行中"<<endl;
- cout<<"-----------------------------------------------------------------| 終點"<<endl;
- int g=rand()%4;
- d[g]++;
- for(int a=0;a<=d[0];a++)
- cout<<" ";
- cout<<"●"<<endl;
- for(int b=0;b<=d[1];b++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int c=0;c<=d[2];c++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int e=0;e<=d[3];e++)
- cout<<" ";
- cout<<"◆"<<endl;
- if(d[0]>=64||d[1]>=64||d[2]>=64||d[3]>=64)
- break;
- _sleep(speed);
- }
- system("pause");
- return 0;
- }
複製代碼 |