- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int number=0;
- re:
- int h[4]={0,0,0,0},r;
- number++;
- srand(time(NULL));
- cout<<"[好事雙城]賽馬場 第"<<number<<"局"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- cout<<"◆"<<endl;
- cout<<"★"<<endl;
- cout<<"▲"<<endl;
- cout<<"●"<<endl;
- system("pause");
- while(true)
- {
- cout<<"比賽進行中...... 第("<<number<<")局"<<endl;
- r=rand()%4;
- h[r]++;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=1;i<=h[0];i++)
- cout<<" ";
- cout<<"◆"<<endl;
- for(int i=1;i<=h[1];i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=1;i<=h[2];i++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int i=1;i<=h[3];i++)
- cout<<" ";
- cout<<"●"<<endl;
- if(h[r]==72)
- {
- break;
- }
- _sleep(1);
- system("cls");
- }
- system("cls");
- cout<<"比賽結束! ";
- if(r==0)
- {
- cout<<"由◆取得領先"<<endl;
- }else if(r==1)
- {
- cout<<"由★取得領先"<<endl;
- }else if(r==2)
- {
- cout<<"由▲取得領先"<<endl;
- }else
- {
- cout<<"由●取得領先"<<endl;
- }
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=1; i<=h[0]; i++)
- cout<<" ";
- cout<<"◆"<<endl;
- for(int i=1; i<=h[1]; i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=1; i<=h[2]; i++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int i=1; i<=h[3]; i++)
- cout<<" ";
- cout<<"●"<<endl;
- system("pause");
- system("cls");
- goto re;
- return 0;
- }
複製代碼 |