- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int m1=0,m2=0;
- int x=1;
- re:
- srand(time(NULL));
- int n[]={0,0,0,0};
- cout<<"「好事成雙」賽馬場第"<<x<<"局"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- string y[]={"◆","★","▲","●"};
- cout<<endl<<endl;
- cout<<"可用餘額: "<<m1<<"元"<<endl;
- int option;
- cout<<"(1)買入 (2)下注 (3)離開 請選擇:"<<endl;
- cin>>option;
- if(option==1){
- cout<<"買入:";
- cin>>m2;
- cout<<m2<<"元"<<endl;
- m1+=m2;
- }
- else if(option==2){
- }
- for(int i=0;i<=3;i++)
- cout<<y[i]<<endl;
- int r=0;
- system("pause");
- while(true){
- system("cls");
- r=rand()%4;
- n[r]++;
- cout<<"比賽進行中,第"<<x<<"局"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0;i<=n[0];i++)
- cout<<" ";
- cout<<"◆"<<endl;
- for(int i=0;i<=n[1];i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=0;i<=n[2];i++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int i=0;i<=n[3];i++)
- cout<<" ";
- cout<<"●"<<endl;
- if(n[r]==73)
- break;
- _sleep(1);
- }system("cls");
- cout<<"比賽結束由"<<y[r]<<"先馳得點!"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0;i<=n[0];i++)
- cout<<" ";
- cout<<"◆"<<endl;
- for(int i=0;i<=n[1];i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=0;i<=n[2];i++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int i=0;i<=n[3];i++)
- cout<<" ";
- cout<<"●"<<endl;
- system("pause");
- x++;
- system("cls");
- goto re;
- return 0;
- }
複製代碼 |