本帖最後由 王瑞喻 於 2019-5-9 23:47 編輯
- #include<iostream>
- #include<cstdlib>
- #include<time>
- using namespace std;
- int main()
- {
- int n=1,money=0; //第n局
- re:
- int a=0,b=0,c=0,d=0,r,option,buyin,bet,horse; //r為亂數選出的馬,x為贏的馬
- system("cls");
- cout<<"賽~馬~"<<"第"<<n<<"局"<<endl;
- cout<<"|起點|--------------------------------------------------------------|終點|"<<endl;
- cout<<"★"<<endl;
- cout<<"㊣"<<endl;
- cout<<"▽"<<endl;
- cout<<"◆"<<endl;
- cout<<endl;
- cout<<"可用餘額:"<<money<<"元"<<endl<<endl;
- cout<<"(1)買入(2)下注(3)離開 請選擇: ";
- cin>>option;
- if(option==1)//買入
- {
- cout<<"買入: ";
- cin>>buyin;
- balance+=buyin; //money=money+buyin
- goto re;
- }else if(option==2)
- {
- cout<<"請下注: ";
- cin>>bet;
- if(bet>money)//下注金額大於餘額
- {
- cout<<"您餘額不足,請重新下注!"<<endl;
- system("pause");
- goto re;
- }else if(bet>=0 && bet<=money)
- {
- money-=bet;//money=money-bet
- cout<<"(1)★(2)㊣(3)▽(4)◆ 請選擇:";
- cin>>horse;
- cout<<"比賽即將開始!"<<endl<<endl;
- }else
- {
- cout<<"您輸入錯誤!請重新下注!"<<endl;
- system("pause");
- goro re;
- }
- }else //離開
- {
- goto end;
- }
- system("pause");
- system("cls");
- srand(time(NULL));
- while(a!=70 && b!=70 && c!=70 && d!=70)
- {
- cout<<"~賽馬進行中~"<<"第"<<n<<"局"<<endl;
- cout<<"|起點|--------------------------------------------------------------|終點|"<<endl;
- r=rand()%4;
- if(r==0)
- {
- a++;
- }
- if(r==1)
- {
- b++;
- }
- if(r==2)
- {
- c++;
- }
- if(r==3)
- {
- 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");
- }
-
- if(a==70)
- {
- cout<<"~比賽結束~"<<"第"<<n<<"局"<<"由★先馳得點!"<<endl;
- }
- else if(b==70)
- {
- cout<<"~比賽結束~"<<"第"<<n<<"局"<<"由㊣先馳得點!"<<endl;
- }
- else if(c==70)
- {
- cout<<"~比賽結束~"<<"第"<<n<<"局"<<"由▽先馳得點!"<<endl;
- }
- else
- {
- cout<<"~比賽結束~"<<"第"<<n<<"局"<<"由◆先馳得點!"<<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;
- system("pause");
- system("cls");
- n++;
- goto re;
- end;
- system("pause");
- return 0;
- }
複製代碼 |