- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int a=1;
- re:
- system("cls");
- srand(time(NULL));
- int s[]={0,0,0,0};
- string p[]={"◆","★","▲","●"};
- int r=0;
- cout<<"賽馬場 第"<<a<<"局"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<4; i++)
- cout<<p[i]<<endl;
- system("pause");
- system("cls");
- while(s[r]<=73)
- {
- r=rand()%4;
- s[r]++;
- cout<<"比賽進行中"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<4; i++)
- {
- for(int j=0; j<s[i]; j++)
- cout<<" ";
- cout<<p[i]<<endl;
- }
- _sleep(50);
- system("cls");
- }
- int max=0,win;
- for(int i=0;i<=3;i++)
- {
- if(max<s[i])
- {
- max=s[i];
- win=i;
- }
- }
-
- cout<<"比賽結束!"<<endl;
- cout<<"由"<<n[win]<<" 先抵達終點!"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<4; i++)
- {
-
- for(int j=0; j<s[i]; j++)
- cout<<" ";
- cout<<p[i]<<endl;
- }
- system("pause");
- a++;
- goto re;
- return 0;
- }
複製代碼 |