本帖最後由 李沛昂 於 2018-6-11 16:53 編輯
- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int dog=1;
- int pig1,pig2=0,pig3=0,pig4,pig5,pig6,pig7;
- re:
- int a,b,c;
- system("cls");
- int pig[]={0,0,0,0};
- srand(time(NULL));
- cout<<"「好事成雙」賭馬場 第"<<dog<<"局"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- cout<<"◆"<<endl;
- cout<<"★"<<endl;
- cout<<"▲"<<endl;
- cout<<"●"<<endl;
- cout<<endl<<"可用餘額: "<<pig3<<endl<<endl;
- re3:
- cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
- cin>>pig2;
- if(pig2==1)
- {
- re1:
- cout<<"買入: ";
- cin>>pig4;
- if(pig4<=0)
- {
- cout<<"你是白癡嗎?看清楚!!!"<<endl;
- _sleep(1500);
- goto re1;
- }
- pig3+=pig4;
- goto re;
- }
- if(pig2==2)
- {
- cout<<"下注: ";
- cin>>pig5;
- if(pig5<=0)
- {
- cout<<"你是白癡嗎?看清楚!!!"<<endl;
- _sleep(1500);
- goto re1;
- }
- if(pig5>pig3)
- {
- cout<<"餘額不夠,請買入!"<<endl;
- _sleep(1500);
- goto re1;
- }
- cout<<"請選擇 (1)◆(2)★(3)▲(4)●: ";
- cin>>pig6;
- cout<<"比賽即將開始......"<<endl;
- _sleep(1500);
- goto re2;
- }
- if(pig2==3)
- {
- goto end;
- }
- else
- {
- cout<<"你是白癡嗎?看清楚!!!"<<endl;
- _sleep(1500);
- goto re3;
- }
- system("pause");
- re2:
- while(true)
- {
- system("cls");
- pig1=rand()%4;
- pig[pig1]++;
- cout<<"比賽進行中"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0;i<=pig[0];i++)
- cout<<" ";
- cout<<"◆"<<endl;
- for(int i=0;i<=pig[1];i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=0;i<=pig[2];i++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int i=0;i<=pig[3];i++)
- cout<<" ";
- cout<<"●"<<endl;
- if(pig[pig1]==73)
- break;
- _sleep(25);
- }
- system("cls");
- if(pig1==0)
- cout<<"比賽結束!"<<" 由◆先馳得點!"<<endl;
- else if(pig1==1)
- cout<<"比賽結束!"<<" 由★先馳得點!"<<endl;
- else if(pig1==2)
- cout<<"比賽結束!"<<" 由▲先馳得點!"<<endl;
- else
- cout<<"比賽結束!"<<" 由●先馳得點!"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0;i<=pig[0];i++)
- cout<<" ";
- cout<<"◆"<<endl;
- for(int i=0;i<=pig[1];i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=0;i<=pig[2];i++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int i=0;i<=pig[3];i++)
- cout<<" ";
- cout<<"●"<<endl;
- if(pig6==1 && pig1==0)
- {
- cout<<"獲得"<<pig5*3<<"元!"<<endl;
- pig7+=pig5*3;
- pig3+=pig5*3;
- }else if(pig6==2 && pig1==1)
- {
- cout<<"獲得"<<pig5*3<<"元!"<<endl;
- pig7+=pig5*3;
- pig3+=pig5*3;
- }else if(pig6==3 && pig1==2)
- {
- cout<<"獲得"<<pig5*3<<"元!"<<endl;
- pig7+=pig5*3;
- pig3+=pig5*3;
- }else if(pig6==4 && pig1==3)
- {
- cout<<"獲得"<<pig5*3<<"元!"<<endl;
- pig7+=pig5*3;
- pig3+=pig5*3;
- }else
- {
- cout<<"損失"<<pig5<<"元!"<<endl;
- pig7-=pig5;
- pig3-=pig5;
- }
- system("pause");
- dog++;
- goto re;
- end:
- if(pig7>0)
- {
- cout<<"恭喜你! 這次總共贏了"<<pig7<<"元!"<<endl;
- }
- else if(pig7==0)
- {
- cout<<"沒輸沒贏! 全身而退!"<<endl;
- }
- else
- {
- cout<<"對不起! 讓你損失了"<<-pig7<<"元!"<<endl;
- }
- cout<<endl<<"謝謝光臨! 下次再來!"<<endl;
- system("pause");
- return 0;
- }
複製代碼 |