本帖最後由 孫嘉駿 於 2020-3-6 18:26 編輯
- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int x=0, l=0;
- re:
- int r=0, q, b, w=0, winner, hos, u, k;
- x+=1;
- system("cls");
- v:
- y:
- r:
- r2:
- system("cls");
- srand(time(NULL));
- string name[]={"「財源廣進」賽馬場","比賽進行中","比賽結束"};
- string horses[]={"◆","★","▲","●"};
- string p[]={"(1) 買入","(2) 下注","(3) 結束"};
- int s[]={0,0,0,0};
- cout<<name[0]<<"第"<<x<<"局"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<=3; i++)
- cout<<horses[i]<<endl;
- cout<<endl;
- l=w+l;
- cout<<"目前剩餘金額: "<<l<<endl;
- for(int a=0; a<=2; a++)
- cout<<p[a];
- cin>>q;
- if(q==1)
- {
- cout<<"買入: ";
- cin>>w;
- cout<<"元"<<endl;
- goto v;
- }else if(q==2)
- {
- goto buy;
- }else if(q==3)
- {
- goto end;
- }else
- {
- cout<<"輸入錯誤!"<<endl;
- _sleep(1500);
- goto y;
- }
- buy:
- cout<<"下注: ";
- cin>>b;
- if(l<=0)
- {
- cout<<"餘額不足,請重新輸入!"<<endl;
- _sleep(1500);
- goto r;
- }else if(l>0 && l>=b)
- {
- cout<<"(1)◆ (2)★ (3)▲ (4)● 請選擇: ";
- cin>>hos;
- cout<<"比賽即將開始..."<<endl;
- }else if(b>l)
- {
- cout<<"餘額不足,請重新輸入!"<<endl;
- _sleep(1500);
- goto r2;
- }
- system("pause");
- system("cls");
- while(s[r]<=73)
- {
- r=rand()%4;
- s[r]+=1;
- cout<<name[1]<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<4; i++)
- {
- for(int j=0; j<s[i]; j++)
- cout<<" ";
- cout<<horses[i]<<endl;
- }
- _sleep(1);
- system("cls");
- }
- winner=r;
- cout<<name[2]<<","<<horses[winner]<<"獲勝!"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<4; i++)
- {
- for(int j=0; j<s[i]; j++)
- cout<<" ";
- cout<<horses[i]<<endl;
- }
- if(winner==hos-1)
- {
- u=3*b;
- l=l+u;
- }if(winner!=hos-1)
- {
- l=l-b;
- k=k+b;
- }
- system("pause");
- goto re;
- end:
- cout<<"☆★☆謝謝參加,下次再來☆★☆"<<endl;
- cout<<"本次贏了: "<<u<<"元"<<endl;
- cout<<"本次輸了: "<<k<<"元"<<endl;
- cout<<"合計: "<<l<<endl;
- return 0;
- }
複製代碼 |