- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- while(true)
- {
- system("cls");
- int s[]={0,0,0,0};
- string n[]={"◆","★","▲","●"};
- srand(time(NULL));
- cout<<"「好事成雙」賽馬場"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int j=0;j<3;j++)
- {
- cout<<n[j]<<endl;
- }
- while(true)
- {
- system("cls");
- int r=rand()%4;
- s[r]++;
- cout<<"比賽進行中"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int k=0; k<=3; k++)
- {
- for(int i=0; i<=s[k]; i++)
- {
- cout<<" ";
- }
- cout<<n[k]<<endl;
- }
-
-
- if(s[r]==72)
- break;
- _sleep(1);
- }
- system("cls");
- cout<<"比賽結束"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- //印空格(看進度是多少就印多少空格)
- //把馬印出來
- for(int k=0; k<=3; k++)
- {
- for(int i=0; i<=s[k]; i++)
- {
- cout<<" ";
- }
- cout<<n[k]<<endl;
- }
- system("pause");
- }
- system("pause");
- return 0;
- }
複製代碼 |