- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int x,y,z,sum=0,money,money2,h,t=1,e=0;
- string b[]{"◆","★","▲","●"};
- re2:
- int a[]{0,0,0,0};
- system("cls");
- cout<<"空蕩蕩賽馬場 第"<<t<<"局"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- cout<<"◆"<<endl;
- cout<<"★"<<endl;
- cout<<"▲"<<endl;
- cout<<"●"<<endl;
- cout<<endl;
- cout<<"可用餘額:"<<sum<<"元"<<endl<<endl;
- cout<<"<1>買入 <2>下注 <3>離開 請選擇:";
- cin>>z;
- if(z==1)
- {
- cout<<endl;
- cout<<"買入: ";
- cin>>money;
- sum+=money;
- goto re2;
- }
- else if(z==2&&sum>0)
- {
- cout<<endl;
- cout<<"下注: ";
- cin>>money2;
- if(sum>=money2)
- {
- cout<<endl;
- sum-=money2;
- re3:
- cout<<"下注幾號 <1>◆ <2>★ <3>▲ <4>● :";
- cin>>h;
- cout<<endl;
- if(h>4||h<1)
- {
- cout<<"輸入錯誤 重新輸入"<<endl<<endl;
- _sleep(1500);
- goto re3;
- }
- }
- else if(sum<money2)
- {
- cout<<"餘額不足請先買入"<<endl;
- _sleep(1500);
- goto re2;
- }
- }
- else if(z==2&&sum<=0)
- {
- cout<<"餘額不足請先買入"<<endl;
- _sleep(1500);
- goto re2;
- }
- else if(z<=0||z>3)
- {
- cout<<"輸入錯誤 重新輸入";
- _sleep(1500);
- goto re2;
- }
- else if(z==3)
- {
- system("pause");
- goto re4;
- }
- system("pause");
- re:
- if(a[0]<73&&a[1]<73&&a[2]<73&&a[3]<73)
- {
- system("cls");
- cout<<"比賽開始"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<=3; i++)
- {
- x=rand()%5+1;
- a[i]+=x;
- }
- for(int i=1; i<=a[0]; i++)
- cout<<" ";
- cout<<"◆"<<endl;
- for(int i=1; i<=a[1]; i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=1; i<=a[2]; i++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int i=1; i<=a[3]; i++)
- cout<<" ";
- cout<<"●"<<endl;
- _sleep(100);
- goto re;
- }
- else
- {
- if(a[0]>=73)
- y=0;
- if(a[1]>=73)
- y=1;
- if(a[2]>=73)
- y=2;
- if(a[3]>=73)
- y=3;
- system("cls");
- cout<<"比賽結束由"<<b[y]<<"獲勝"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=1; i<=a[0]; i++)
- cout<<" ";
- cout<<"◆"<<endl;
- for(int i=1; i<=a[1]; i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=1; i<=a[2]; i++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int i=1; i<=a[3]; i++)
- cout<<" ";
- cout<<"●"<<endl;
- }
- if(y+1==h)
- {
- cout<<"賺到"<<money2*3<<"元"<<endl;
- sum+=money2*4;
- e+=money2*3;
- }
- if(y+1!=h)
- {
- cout<<"損失"<<money2<<"元"<<endl;
- e-=money2;
- }
- system("pause");
- t+=1;
- goto re2;
- re4:
- if(e>0)
- {
- cout<<"恭喜你!這次總共贏了"<<e<<"元!"<<endl<<endl;
- cout<<"謝謝光臨 下次還來"<<endl;
- }
- else if(e<0)
- {
- cout<<"不好意思!讓你損失了"<<-e<<"元!"<<endl<<endl;
- cout<<"謝謝光臨 下次還來"<<endl;
- }
- else
- {
- cout<<"沒輸沒贏!全身而退!"<<endl<<endl;
- cout<<"謝謝光臨 下次還來"<<endl;
- }
- cout<<
- system("pause");
- return 0;
- }
複製代碼 |