- #include<bits/stdc++.h>
- using namespace std;
- int n=0;
- int main()
- {
- re:
- n++;
- system("cls");
- int s[4]= {0,0,0,0};
- string p[4]= {"馬1","馬2","馬3","馬4"};
- int r;
- srand(time(NULL));
- cout<<"[好事成雙]賽馬場 第"<<n<<"局"<<endl;
- cout<<"-------------------------------------------------------------------------|終點"<<endl;
- for(int i=0; i<4; i++)
- {
- cout<<p[i]<<endl;
- }
- system("pause");
- system("cls");
- while(s[r]<=74)
- {
- r=rand()%4;
- s[r]++;
- cout<<"比賽進行中"<<endl;
- cout<<"-----------------------------------------------------------------------------|終點"<<endl;
- for(int i=0; i<=3; i++)
- {
- for(int j=0; j<s[i]; j++)
- {
- cout<<" ";
- }
- cout<<p[i]<<endl;
- }
- _sleep(50);
- system("cls");
- }
- cout<<"比賽結束,由"<<p[r]<<"先馳得點!"<<endl;
- cout<<"-------------------------------------------------------------------------|終點"<<endl;
- for(int i=0; i<=3; i++)
- {
- for(int j=0; j<s[i]; j++)
- {
- cout<<" ";
- }
- cout<<p[i]<<endl;
- }
- goto re;
- system("pause");
- return 0;
- }
複製代碼 |