- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- re:
- system("cls");
- int s[]={0,0,0,0};
- string h[]={"◆","★","▲","●"};
- srand(time(NULL));
- cout<<"「好事成雙」賽馬場"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0;i<4;i++)
- {
- cout<<h[i]<<endl;
- }
- system("pause");
- while(true)
- {
- system("cls");
- int r=rand()%4;
- s[r]++;
- cout<<"比賽進行中"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int j=0;j<4;j++)
- {
- for(int i=0;i<s[j];i++)
- {
- cout<<" ";
- }
- cout<<h[j]<<endl;
- }
-
-
- if(s[r]==73)
- {
- break;
- _sleep(50);
- }
- }
- system("cls");
- cout<<"比賽結束"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int x=0;x<4;x++)
- {
- for(int y=0;y<s[x];y++)
- {
- cout<<" ";
- }
- cout<<h[x]<<endl;
- }
- system("pause");
- goto re;
- return 0;
- }
複製代碼 |