- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main(){
- string h[]={"◆","★","▲","●"};
- int m=0,m1,m2,option1,option2,x=1,y,r;
- int n[]={0,0,0,0};
- srand(time(NULL));
- re:
- system("cls");
- cout<<"好事成雙賽馬場 第"<<x<<"場"<<endl;
- cout<<"----------------------------------------------------------------------|終點"<<endl;
- for(int i=0;i<4;i++)
- cout<<h[i]<<endl;
- re2:
- cout<<endl<<"可用餘額:"<<m<<"元"<<endl;
- cout<<"(1)買入 (2)下注 (3)離開 請選擇:"<<endl;
- cin>>option1;
- if(option1==1){
- cout<<"買入:";
- cin>>m1;
- if(m1<=0){
- cout<<"輸入錯誤"<<endl;
- _sleep(1500);
- goto re;
- }
- m+=m1;
- goto re;
- }
- else if(option1==2){
- cout<<"下注:";
- cin>>m2;
- if(m2<=0){
- cout<<"輸入錯誤"<<endl;
- _sleep(1500);
- goto re;
- }
- if(m2>m){
- cout<<"餘額不足"<<endl;
- _sleep(1500);
- goto re;
- }
- cout<<"(1)◆ (2)★ (3)▲ (4)●請選擇:"<<endl;
- cin>>option2;
- cout<<"比賽即將開始...."<<endl;
- }
- else if(option1==3){
- goto end;
- }
- else{
- cout<<"輸入錯誤"<<endl;
- _sleep(1500);
- system("cls");
- goto re2;
- }
- system("pause");
- system("cls");
- while(n[r]<73){
- r=rand()%4;
- n[r]++;
- _sleep(0.1);
- cout<<"比賽進行中"<<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(50);
- system("cls");
- }
- system("cls");
- cout<<"比賽結束 由"<<h[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;
- if(option2==r+1){
- cout<<"賺到"<<m2*3<<"元"<<endl;
- m+=m2*3;
- }
- else{
- cout<<"賠"<<m2<<"元"<<endl;
- m-=m2;
- }
- system("pause");
- system("cls");
- x++;
- goto re;
- end:
- cout<<"慢走!"<<endl;
- _sleep(1500);
- return 0;
- }
複製代碼 |