- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int round=1;
- while(true)
- {
- system("cls");
- int s[]={0,0,0,0};
- string p[]={"◆","★","▲","●"};
- srand(time(NULL));
-
- cout<<"「好事成雙」賽馬場 第"<<round<<"局"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0;i<=3;i++)
- {
- cout<<p[i]<<endl;
- }
- while(true)
- {
- system("cls");
- int r=rand()%4;
- s[r]++;
- cout<<"比賽進行中"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int j=0; j<=3; j++)
- {
- for(int i=0; i<=s[j]; i++)
- cout<<" ";
- cout<<p[j]<<endl;
- }
- if(s[r]==72)
- break;
- _sleep(0.005);
- }
- string win;
- for(int i=0; i<=3; i++)
- {
- if(s[i]==73)
- {
- win=p[i];
- }
- }
- cout<<"比賽結束"<<win<<"贏"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int j=0; j<=3; j++)
- {
- for(int i=0; i<=s[j]; i++)
- cout<<" ";
- cout<<p[j]<<endl;
- system("pause");
- round++;
- }
-
- }
- system("pause");
- return 0;
- }
複製代碼 |