本帖最後由 邱品惟 於 2023-8-15 20:01 編輯
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int monny=0,choose,x,y,m,r,d;
- int round=1;
- re:
- int s[]={0,0,0,0};
- string p[]={"◆","★","▲","●"};
- srand(time(NULL));
- cout<<"「好事成雙」賽馬場第"<<round<<"場"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<4; i++)
- cout<<p[i]<<endl;
- cout<<endl;
- cout<<"可用餘額:"<<monny<<endl<<endl;
- cout<<"(1)買入 (2)下注 (3)離開 (4)開始賽馬"<<endl;
- cin>>choose;
- if(choose==1)
- {
- cout<<"儲值";
- cin>>m;
- monny=m+monny;
- system("cls");
- goto re;
- }
- else if(choose==2)
- {
- cout<<"(1)◆ (2)★ (3)▲ (4)●"<<endl;
- cin>>y;
- if(y<=4&&y>=1)
- {
- cout<<"下注"<<endl;
- cin>>x;
- if(monny>=x)
- {
- monny=monny-x;
- system("cls");
- }
- else if(x>monny)
- {
- cout<<"你還不夠"<<x-monny<<"元"<<endl;
- system("pause");
- system("cls");
- }
- goto re;
- }
- else
- {
- cout<<"輸入錯誤"<<endl;
- system("pause");
- system("cls");
- goto re;
- }
-
-
- }
- else if(choose==3)
- {
- goto bye;
- }
- else if(choose==4)
- {
- if(x==0)
- {
- cout<<"你真的不賭?";
- cout<<"(1)賭 (2)不賭";
- cin>>d;
- if(d==1)
- {
- system("cls");
- goto re;
- }
- if(d==2)
- {
- goto see;
- }
- }
- }
- else
- {
- cout<<"輸入錯誤"<<endl;
- system("pause");
- system("cls");
- goto re;
- }
- see:
- system("pause");
- while(true)
- {
- system("cls");
- r=rand()%4;
- s[r]++;
- cout<<"比賽進行中"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<=s[0]; i++)
- cout<<" ";
- cout<<"◆"<<endl;
- for(int i=0; i<=s[1]; i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=0; i<=s[2]; i++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int i=0; i<=s[3]; i++)
- cout<<" ";
- cout<<"●"<<endl;
- if(s[r]==73)
- break;
-
- }
- system("cls");
- cout<<"比賽結束"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<=s[0]; i++)
- cout<<" ";
- cout<<"◆"<<endl;
- for(int i=0; i<=s[1]; i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=0; i<=s[2]; i++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int i=0; i<=s[3]; i++)
- cout<<" ";
- cout<<"●"<<endl;
- round=round+1;
- cout<<"恭喜"<<p[r]<<"獲勝"<<endl;
- if(y-1==r)
- {
- cout<<"恭喜你押對了,得到了雙倍"<<endl;
- monny=monny+x*2;
- }
- else
- cout<<"謝謝你的錢,我會拿去吃好料的"<<endl;
- system("pause");
- system("cls");
- x=0;
- goto re;
- bye:
- if(monny+x>0)
- {
- cout<<"還你"<<monny+x<<"元"<<endl;
- }
- system("pause");
- return 0;
- }
複製代碼 |