- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- re1:
- int a=0, b=0, c=0, d=0, r;
- system("cls");
- cout<<"「好事成雙」賽馬場"<<endl;
- cout<<"------------------------------------------------------------------------| 終點"<<endl;
- cout<<"◆"<<endl;
- cout<<"★"<<endl;
- cout<<"▲"<<endl;
- cout<<"●"<<endl;
- system("pause");
- system("cls");
- srand(time(NULL));
- while(a!=75 && b!=75 && c!=75 && d!=75)
- {
- r=rand()%4; //產生0~3之隨機亂數
- if(r==0)
- a++;
- else if(r==1)
- b++;
- else if(r==2)
- c++;
- else
- d++;
- cout<<"比賽進行中"<<endl;
- cout<<"------------------------------------------------------------------------| 終點"<<endl;
- for(int i=1; i<=a; i++)
- cout<<" ";
- cout<<"◆"<<endl;
- for(int i=1; i<=b; i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=1; i<=c; i++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int i=1; i<=d; i++)
- cout<<" ";
- cout<<"●"<<endl;
- system("cls");
- }
- cout<<"比賽結束"<<endl;
- cout<<"------------------------------------------------------------------------| 終點"<<endl;
- for(int i=1; i<=a; i++)
- cout<<" ";
- cout<<"◆"<<endl;
- for(int i=1; i<=b; i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=1; i<=c; i++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int i=1; i<=d; i++)
- cout<<" ";
- cout<<"●"<<endl;
- system("pause");
- goto re1;
- system("pause");
- return 0;
- }
複製代碼 |