本帖最後由 吳孟書 於 2019-5-4 13:19 編輯
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int t=1,m=0;
- re:
- system("cls");
- int a=0,b=0,c=0,d=0,r,choose,in,bet,h,w;
- cout<<"「好事成雙」賽馬場 第"<<t<<"局"<<endl;
- cout<<"------------------------------------------------------------------------| 終點"<<endl;
- cout<<"◆"<<endl;
- cout<<"★"<<endl;
- cout<<"▲"<<endl;
- cout<<"●"<<endl<<endl;
- cout<<"可用餘額:"<<m<<"元"<<endl<<endl;
- cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
- cin>>choose;
- if(choose==1)
- {
- w1:
- cout<<"買入: ";
- cin>>in;
- if(in>0)
- {
- m=m+in;
- goto re;
- }
- else
- {
- cout<<"輸入錯誤"<<endl;
- system("pause");
- goto w1;
- }
- }else if(choose==2)
- {
- cout<<"請下注:";
- cin>>bet;
- cout<<endl;
- if(bet>m)
- {
- cout<<"您餘額不足,請重新輸入!"<<endl;
- system("pause");
- goto re;
- }else if(bet>=0 && bet<= m)
- {
- cout<<"(1)◆ (2)★ (3)▲(4)● 請選擇:";
- cin>>h;
- cout<<"比賽即將開始!"<<endl<<endl;
- }else
- {
- cout<<"輸入錯誤"<<endl;
- system("pause");
- goto re;
- }
- }else if(choose==3)
- {
- goto end;
- }else
- {
- cout<<"輸入錯誤"<<endl;
- system("pause");
- goto re;
- }
- system("pause");
- system("cls");
- srand(time(NULL));
- while(a!=70 && b!=70 && c!=70 && d!=70)
- {
- cout<<"比賽進行中"<<endl;
- cout<<"------------------------------------------------------------------------| 終點"<<endl;
- r=rand()%4+1;
- if(r==1)
- {
- a++;
- }
- if(r==2)
- {
- b++;
- }
- if(r==3)
- {
- c++;
- }
- if(r==4)
- {
- d++;
- }
- for(int i=0;i<=a;i++)
- {
- cout<<" ";
- }
- cout<<"◆"<<endl;
- for(int i=0;i<=b;i++)
- {
- cout<<" ";
- }
- cout<<"★"<<endl;
- for(int i=0;i<=c;i++)
- {
- cout<<" ";
- }
- cout<<"▲"<<endl;
- for(int i=0;i<=d;i++)
- {
- cout<<" ";
- }
- cout<<"●"<<endl;
- system("cls");
- }
- cout<<"比賽結束!由";
- if(a==70)
- {
- cout<<"◆";
- w=1;
- }
- else if(b==70)
- {
- cout<<"★";
- w=2;
- }
- else if(c==70)
- {
- cout<<"▲";
- w=3;
- }
- else if(d==70)
- {
- cout<<"●";
- w=4;
- }
- cout<<"勝出!"<<endl;
- cout<<"------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0;i<=a;i++)
- {
- cout<<" ";
- }
- cout<<"◆"<<endl;
- for(int i=0;i<=b;i++)
- {
- cout<<" ";
- }
- cout<<"★"<<endl;
- for(int i=0;i<=c;i++)
- {
- cout<<" ";
- }
- cout<<"▲"<<endl;
- for(int i=0;i<=d;i++)
- {
- cout<<" ";
- }
- cout<<"●"<<endl;
- if(h==w)
- {
- m=m+bet*3;
- cout<<"贏了"<<bet*3<<"元"<<endl;
- }else
- {
- m=m-bet;
- cout<<"損失"<<bet<<"元"<<endl;
- }
- system("pause");
- system("cls");
- t++;
- goto re;
- end:
- system("pause");
- return 0;
- }
複製代碼 |