本帖最後由 陳妍蓁 於 2024-8-10 11:58 編輯
- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int n=0,m=0,sum=0,m1,m2,r,x;
- int option1,option2;
- string h[]={"◆","★","▲","●"};
- int a[]={0,0,0,0};
- srand(time(NULL));
- re:
- system("cls");
- cout<<"好事成雙賽馬場 第"<<x<<"局"<<endl;
- cout<<"----------------------------------------------------------------------------|終點"<<endl;
- for(int i=0;i<=3;i++)
- cout<<h[i]<<endl;
- re2:
- cout<<endl<<"可用餘額"<<m<<"元"<<endl<<endl;
- cout<<"(1)買入 (2)下注 (3)離開 請選擇:"<<endl;
- cin>>option1;
- if(option1==1){
- cout<<"(1)買入:";
- cin>>m1;
- cout<<"元"<<endl;
- if(m1<=0){
- cout<<"輸入錯誤"<<endl;
- _sleep(1500);
- goto re;
- }
- m=m1++;
- sum+=m1;
- goto re;
- }
- else if (option1==2){
- cout<<"下注:";
- cin>>m2;
- if(m2<=0 || m2>m){
- cout<<"輸入錯誤"<<endl;
- _sleep(1500);
- goto re;
- }
- cout<<"請選擇:(1)◆ (2)★ (3)▲ (4)●";
- cin>>option2;
- cout<<"比賽即將開始..."<<endl;
- }
- else if(option1==3){
- goto end;
- }
- else
- goto re;
- system("pause");
- while(true){
- system("cls");
- cout<<"比賽進行中"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- r=rand()%4;
- a[r]++;
- _sleep(5);
- for(int i=0;i<=a[0];i++)
- cout<<" ";
- cout<<"◆"<<endl;
- for(int i=0;i<=a[1];i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=0;i<=a[2];i++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int i=0;i<=a[3];i++)
- cout<<" ";
- cout<<"●"<<endl;
- if(a[r]==73){
- break;
- _sleep(50);
- system("cls");
- }
- }
- system("cls");
- cout<<"比賽結束 由:"<<h[r]<<"勝出"<<endl;
- cout<<"----------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0;i<=a[0];i++)
- cout<<" ";
- cout<<"◆"<<endl;
- for(int i=0;i<=a[1];i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=0;i<=a[2];i++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int i=0;i<=a[3];i++)
- cout<<" ";
- cout<<"●"<<endl;
- if(option2==r+1){
- cout<<"賺到"<<m2*3<<"元"<<endl;
- m+=m2*3;
- }
- else{
- cout<<"賠"<<m2<<"元"<<endl;
- m-=m2;
- }
- system("pause");
- r++;
- goto re;
- end:
- if(sum==m)
- cout<<"沒輸沒贏!全身而退!"<<endl<<endl;
- else if(sum<m)
- cout<<"恭喜你!這次總共贏了"<<m-sum<<"元!"<<endl<<endl;
- else if(sum>m)
- cout<<"不好意思!讓你損失了"<<sum-m<<"元!"<<endl<<endl;
- cout<<"謝謝光臨,下次再來"<<endl;
- _sleep(50);
- return 0;
- }
複製代碼 |