- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int s=1,m=0,bg=0;
- re:
-
- int a=0,b=0,c=0,d=0,r,o,z,h,w;
- system("cls");
- cout<<"賽馬場 第"<<s<<"局"<<endl;
- cout<<"--------------------------------------------------------------------|終點"<<endl;
-
- cout<<"◆"<<endl;
- cout<<"★"<<endl;
- cout<<"▲"<<endl;
- cout<<"●"<<endl;
- cout<<"可用餘額: "<<m<<"元"<<endl<<endl;
- cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
- cin>>o;
- if(o==1)
- {
- cout<<"買入: ";
- cin>>z;
- m=m+z;
- goto re;
- }else if(o==2)
- {
- cout<<"請下注: ";
- cin>>z;
- if(z > m)
- {
- cout<<"餘額不足,請重新下注!"<<endl;
- system("pause");
- goto re;
- }else if(z>=0 && z<= m)
- {
- cout<<"(1)◆馬 (2)★馬 (3)▲馬 (4)●馬 請選擇:";
- cin>>h;
- cout<<"比賽即將開始!"<<endl<<endl;
- }
- }else if(o==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==75)
- {
- cout<<"◆";
- w = 1;
- }
- else if(b==75)
- {
- cout<<"★";
- w = 2;
- }
- else if(c==75)
- {
- cout<<"▲";
- w = 3;
- }
- else
- {
- 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+(z*3);
- cout<<"贏了"<<z*3<<"元!"<<endl;
- bg+=z*3;
- }else
- {
- m=m-z;
- cout<<"損失"<<z<<"元!"<<endl;
- bg-=z;
- }
-
- system("pause");
- s++;
- goto re;
- end:
-
- if(bg==0)
- {
- cout<<"沒輸沒贏!"<<endl;
- }else if(bg>0)
- {
- cout<<"恭喜你! 這次總共贏了"<<bg<<"元!"<<endl;
- }else
- {
- cout<<"哈哈 你損失了"<<-bg<<"元!"<<endl;
- }
- cout<<"銘謝惠顧! 下次再來!"<<endl;
-
- system("pause");
- return 0;
- }
複製代碼 |