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