本帖最後由 高昀昊 於 2022-3-26 15:52 編輯
老師,我先全部做完了喔
(而且不知道為什麼複製貼上之後縮排會有點跑掉)- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int n =1,blance=0;
- re:
- system("cls");
- int a=0,b=0,c=0,d=0,r, option, buyin =0 ,pay ,choose ;
- string words ="賽馬進行中";
- string name[4] = {"◆","★","▲","●"};
- int position =0;
- cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
- cout<<"------------------------------------------------------------------------| 終點"<<endl;
- cout<<"◆"<<endl;
- cout<<"★"<<endl;
- cout<<"▲"<<endl;
- cout<<"●"<<endl;
- cout<<endl;
- cout<<"可用餘額:"<<blance<<"元"<<endl;
- cout<<endl;
- back:
- cout<<"(1)買入 (2)下注 (3)純粹觀賽 (4)離開 請選擇:";
- cin>>option;
- if(option==1)
- {
- cout<<"買入:";
- cin>>buyin;
- blance += buyin;
- goto re;
- }else if(option==2)
- {
- cout<<"請下注:";
- cin>>pay;
- if(pay>blance)
- {
- cout<<"您餘額不足,請重新下注"<<endl;
- system("pause");
- goto back;
- }
- if(pay<=0)
- {
- cout<<"輸入錯誤"<<endl;
- goto back;
- }
- cout<<"(1)◆ (2)★ (3)▲ (4)● (5)離開 請選擇:";
- cin>>choose;
- if(choose==1)
- {
- }else if(choose==2)
- {
- }else if(choose==3)
- {
- }else if(choose==4)
- {
- }else if(choose==5)
- {
- goto back;
- }else {
- cout<<"輸入錯誤"<<endl;
- goto back;
- }
- blance-=pay;
- }else if(option==3)
- {
- goto play;
- }else if(option==4)
- {
- goto end;
- }else{
- cout<<"輸入錯誤"<<endl;
- goto back;
- }
- play:
- system("pause");
- system("cls");
- srand(time(NULL));
- while(a<=70 && b<=70 && c<=70 && d<=70)
- {
- cout<<words<<endl;
- cout<<"------------------------------------------------------------------------| 終點"<<endl;
- if(a==70)
- {
- a++;
- goto over;
- }
- if(b==70)
- {
- b++;
- goto over;
- }
- if(c==70)
- {
- c++;
- goto over;
- }
- if(d==70)
- {
- d++;
- goto over;
- }
- r = rand()%4+1;
- switch(r)
- {
- case 1:
- a++;
- break;
- case 2:
- b++;
- break;
- case 3:
- c++;
- break;
- case 4:
- d++;
- break;
- }
- over:
- for(int i=0;i<=a;i++)
- {
- cout<<" ";
- }
- cout<<name[0]<<endl;
- for(int i=0;i<=b;i++)
- {
- cout<<" ";
- }
- cout<<name[1]<<endl;
- for(int i=0;i<=c;i++)
- {
- cout<<" ";
- }
- cout<<name[2]<<endl;
- for(int i=0;i<=d;i++)
- {
- cout<<" ";
- }
- cout<<name[3]<<endl;
- if(a==70 || b==70 || c==70 || d==70)
- {
- if(a==70)
- position = 0;
- if(b==70)
- position =1;
- if(c==70)
- position =2;
- if(d==70)
- position =3;
- words = "比賽結束!由"+name[position]+"先馳得點!";
- }
- if(a==71 || b==71 || c==71 || d==71)
- {
- if(option==3)
- goto keep;
- if(position==0)
- {
- if(choose==1)
- {
- cout<<"恭喜,你賭贏了,獲得4倍的獎金"<<endl;
- blance+=4*pay;
- }else{
- cout<<"可惜,你輸了,再接再厲"<<endl;
- }
- }else if(position==1)
- {
- if(choose==2)
- {
- cout<<"恭喜,你賭贏了,獲得4倍的獎金"<<endl;
- blance+=4*pay;
- }else{
- cout<<"可惜,你輸了,再接再厲"<<endl;
- }
- }else if(position==2)
- {
- if(choose==3)
- {
- cout<<"恭喜,你賭贏了,獲得4倍的獎金"<<endl;
- blance+=4*pay;
- }else{
- cout<<"可惜,你輸了,再接再厲"<<endl;
- }
- }else if(position==3)
- {
- if(choose==4)
- {
- cout<<"恭喜,你賭贏了,獲得4倍的獎金"<<endl;
- blance+=4*pay;
- }else{
- cout<<"可惜,你輸了,再接再厲"<<endl;
- }
- }
- }else{
- system("cls");
- }
- }
- keep:
- n++;
- system("pause");
- goto re;
- end:
- return 0;
- }
複製代碼 |