- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n=0;
- for(int a=0; a<5; a++)
- {
- n++;
- system("cls");
- int s[4]= {0,0,0,0};
- int r;
- int speed=1;
- srand(time(NULL));
- cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
- cout<<"--------------------------------|終點"<<endl;
- string p[4]= {"◆","★","▲","●"};
- for(int i=0; i<=3; i++)
- {
- cout<<p[i]<<endl;
- }
- system("pause");
- system("cls");
- while(s[r]<=30)
- {
- 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(speed);
- 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;
- }
- system("pause");
- }
- system("pause");
- return 0;
- }
複製代碼 |