- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int s[]={0,0,0,0};
- string k[]={"◆","★","▲","●"};
- int o, r, balance=0, option, buyin, bet, contestant;
-
-
-
- re:
- o++;
-
- be:
- system("cls");
- srand(time(NULL));
-
-
- cout<<"「好事成雙」賽馬場 第"<<o<<"局"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- cout<<"◆"<<endl;
- cout<<"★"<<endl;
- cout<<"▲"<<endl;
- cout<<"●"<<endl<<endl;
- option=0;
- cout<<"可用餘額: "<<balance<<"元"<<endl<<endl;
- cout<<"<1>買入 <2>下注 <3>離開 請選擇: ";
- cin>>option;
-
- if(option==1){
- cout<<"買入: ";
- cin>>buyin;
- if(buyin<=0){
- cout<<"輸入錯誤";
- _sleep(1500);
- goto be;
- }
- else{
- balance+=buyin;
- goto be;}
- }
- else if(option==2){
- cout<<"下注: ";
- cin>>bet;
- if(bet > balance){
- cout<<"餘額不足!!請買入"<<endl;
- _sleep(1500);
- goto be;
- }
- else if (bet>0 && bet<=balance){
- cout<<"<1>◆ <2>★ <3>▲ <4>● 請選擇: ";
- cin>>contestant;
- }
- else{
- cout<<"輸入錯誤";
- _sleep(1500);
- goto be;
- }
-
- }
-
- else if(option==3){
- goto end;
- }
- else{
- cout<<"輸入錯誤"<<endl;
- _sleep(1500);
- goto be;
- }
-
-
- system("pause");
- while(true)
- {
- system("cls");
- r=rand()%4;
- s[r]++;
- cout<<"比賽進行中 第"<<o<<"局"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<=s[0]; i++)
- cout<<" ";
- cout<<"◆"<<endl;
- for(int i=0; i<=s[1]; i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=0; i<=s[2]; i++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int i=0; i<=s[3]; i++)
- cout<<" ";
- cout<<"●"<<endl;
- if(s[r]==73)
- break;
- _sleep(50);
- }
-
-
- system("cls");
- cout<<"比賽結束 由"<<k[r]<<"獲勝"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<=s[0]; i++)
- cout<<" ";
- cout<<"◆"<<endl;
- for(int i=0; i<=s[1]; i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=0; i<=s[2]; i++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int i=0; i<=s[3]; i++)
- cout<<" ";
- cout<<"●"<<endl;
-
- if(contestant - 1 == r){
- cout<<"你獲得"<<bet*3<<"元"<<endl;
- balance+=(bet*3);
- }
- else{
- cout<<"你輸了"<<bet<<"元"<<endl;
- balance-=bet;
- }
- cout<<"可用餘額: "<<balance<<"元"<<endl<<endl;
- cout<<"<1>買入 <2>下注 <3>離開 請選擇: ";
- cin>>option;
-
- system("pause");
- goto re;
-
- end:
- cout<<"Bye Bye";
- return 0;
- }
複製代碼 |