- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
-
- int money=0,cg,n=1,buy,bet,player,choose;
- choose:
- cout<<"第"<<n<<"場"<<endl;
- cout<<"*準備輸光吧賽馬場*"<<endl;
- cout<<endl<<"-----------------------------------------------------------------------|終點|"<<endl;
- cout<<"◢1◤"<<endl;
- cout<<"◢2◤"<<endl;
- cout<<"◢3◤"<<endl;
- cout<<"◢4◤"<<endl;
- cout<<"您有"<<money<<"元"<<endl;
- cout<<"需先買入並下注"<<endl;
- cout<<"(1)買入(2)賭(3)離開"<<endl;
- cin>>choose;
- if(choose==1)
- {
- cout<<"買多少?"<<endl;
- cin>>buy;
- money=money+buy;
- system("cls");
- goto choose;
- }else if(choose==2)
- {
- cout<<"想賭哪位選手(共有4位)"<<endl;
- cin>>player;
- if(player>4 || player<1)
- {
- system("cls");
- goto choose;
- }
- cout<<"想賭多少?"<<endl;
- cin>>bet;
- if(bet>money)
- {
- system("cls");
- goto choose;
- }
- cout<<"(1)比賽開始(2)重選"<<endl;
- cin>>cg;
- system("cls");
- if(cg==1)
- goto re;
- else if(cg==2)
- goto choose;
- else
- cout<<"輸入錯誤"<<endl;
- goto choose;
- }else if(choose==3)
- {
- system("cls");
- }
- else
- cout<<"輸入錯誤"<<endl;
- system("cls");
- goto choose;
- re:
- cout<<"*準備輸光吧賽馬場*"<<endl<<endl;
- cout<<endl<<"-----------------------------------------------------------------------|終點|"<<endl;
- cout<<"◢1◤"<<endl;
- cout<<"◢2◤"<<endl;
- cout<<"◢3◤"<<endl;
- cout<<"◢4◤"<<endl;
- system("pause");
- system("cls");
- srand(time(NULL));
- int a=0 ,b=0, c=0, d=0,r,bigger,biggest,more;
- while((a!=65) && (b!=65) && (c!=65) && (d!=65))
- {
- r=rand()%4;
- if(r==0)
- a++;
- else if(r==1)
- b++;
- else if(r==2)
- c++;
- else if(r==3)
- d++;
- cout<<"比賽進行中"<<endl<<endl;
- cout<<endl<<"-----------------------------------------------------------------|終點|"<<endl;
- for(int i=1;i<=a;i++)
- cout<<" ";
- cout<<"◢1◤"<<endl;
- for(int i=1;i<=b;i++)
- cout<<" ";
- cout<<"◢2◤"<<endl;
- for(int i=1;i<=c;i++)
- cout<<" ";
- cout<<"◢3◤"<<endl;
- for(int i=1;i<=d;i++)
- cout<<" ";
- cout<<"◢4◤"<<endl;
- system("cls");
- }
- more=(a>b)?a:b;
- bigger=(c>d)?c:d;
- biggest=(bigger>more)?bigger:more;
- if(biggest==a)
- cout<<"1號勝利"<<endl;
- else if(biggest==b)
- cout<<"2號勝利"<<endl;
- else if(biggest==c)
- cout<<"3號勝利"<<endl;
- else if(biggest==d)
- cout<<"4號勝利"<<endl;
- cout<<"第"<<n<<"場"<<endl;
- cout<<endl<<"-----------------------------------------------------------------|終點|"<<endl;
- for(int i=1;i<=a;i++)
- cout<<" ";
- cout<<"◢1◤"<<endl;
- for(int i=1;i<=b;i++)
- cout<<" ";
- cout<<"◢2◤"<<endl;
- for(int i=1;i<=c;i++)
- cout<<" ";
- cout<<"◢3◤"<<endl;
- for(int i=1;i<=d;i++)
- cout<<" ";
- cout<<"◢4◤"<<endl;
- n++;
- if(biggest==a && player==1)
- {
- money=money+bet;
- cout<<"恭喜你贏了"<<bet<<"元"<<endl;
- }else if(biggest==b && player==2)
- {
- money=money+bet;
- cout<<"恭喜你贏了"<<bet<<"元"<<endl;
- }else if(biggest==c && player==3)
- {
- money==money+bet;
- cout<<"恭喜你贏了"<<bet<<"元"<<endl;
- }else if(biggest==d && player==4)
- {
- money=money+bet;
- cout<<"恭喜你贏了"<<bet<<"元"<<endl;
- }else
- {
- money=money-bet;
- cout<<"恭喜你輸了"<<bet<<"元"<<endl;
- }
- system("pause");
- system("cls");
- goto choose;
- system("pause");
- return 0;
- }
複製代碼 |