- #include<iostream>
- #include<cstdlib>
- #include<time.h>
- using namespace std;
- int main()
- {
- int money=0,choose,buyin,down,r,n=1,again;
-
- srand(time(NULL));
- re:
- int h[4] = {0,0,0,0};
- cout<<"賽馬場\n---------------------------------------------------|終點\n◆\n★\n▲\n●\n";
- cout<<"可用餘額:"<<money<<"元\n(1)買入 (2)下注 (3)進入比賽 (4)退出 請選擇:";
- cin>>choose;
- if(choose==1)
- {
- cout<<"要買入多少:";
- cin>>buyin;
- if(buyin<=0)
- {
- cout<<"不好意思,輸入錯誤";
- }
- else
- {
- money+=buyin;
- }
- _sleep(1500);
- system("cls");
- goto re;
- }
- else if(choose==2)
- {
- cout<<"要下注多少:";
- cin>>down;
- if(down<=0||down>money)
- {
- cout<<"不好意思,輸入錯誤";
- }
- else
- {
- money-=down;
- }
- _sleep(1500);
- system("cls");
- goto re;
- }
- else if(choose == 3)
- {
- _sleep(500);
- system("cls");
- goto re3;
- }
- else if(choose == 4)
- goto re2;
- else
- {
- cout<<"不好意思,輸入錯誤";
- _sleep(1500);
- system("cls");
- goto re;
- }
- re3:
-
- while(true)
- {
- cout<<"第"<<n<<"局比賽中\n---------------------------------------------------|終點\n";
- r = rand()%4;
- h[r]++;
- for(int i=1;i<=h[0];i++)
- {
- cout<<" ";
- }
- cout<<"◆\n";
- for(int i=1;i<=h[1];i++)
- {
- cout<<" ";
- }
- cout<<"★\n";
- for(int i=1;i<=h[2];i++)
- {
- cout<<" ";
- }
- cout<<"▲\n";
- for(int i=1;i<=h[3];i++)
- {
- cout<<" ";
- }
- cout<<"●\n";
- if(h[r]>=50)
- {
- if(r==0)
- {
- cout<<"◆獲勝";
- }
- if(r==1)
- {
- cout<<"★獲勝";
- }if(r==2)
- {
- cout<<"▲獲勝";
- }if(r==3)
- {
- cout<<"●獲勝";
- }
- _sleep(2000);
- system("cls");
- n++;
- break;
- }
- _sleep(50);
- system("cls");
- }
- re4:
- cout<<"要繼續嗎? 1.要2.不要 請選擇:";
- cin>>again;
- if(again == 1)
- {
- goto re;
- }
- else if(again == 2)
- {
- goto re2;
- }
- else
- {
- cout<<"不好意思,輸入錯誤";
- _sleep(1500);
- system("cls");
- goto re4;
- }
- re2:
- system("pause");
- return 0;
- }
複製代碼 |