- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int round=1;
- int balance=0;
- int option;
- int buy;
- re:
- system("cls");
- int s[]={0,0,0,0};
- string h[]={"◆","★","▲","●"};
- srand(time(NULL));
- cout<<"「好事成雙」賽馬場,第"<<round<<"局"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0;i<4;i++)
- {
- cout<<h[i]<<endl;
- }
- cout<<"可用餘額"<<balance<<"元";
- cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
- cin>>option;
- if(option==1)
- {
- cout<<"你要儲值多少元?";
- cin>>buy;
- cout<<"買入"<<buy<<"元";
- balance=buy+balance;
- goto re;
- }
- system("pause");
- while(true)
- {
- system("cls");
- int r=rand()%4;
- s[r]++;
- cout<<"比賽進行中"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int j=0;j<4;j++)
- {
- for(int i=0;i<s[j];i++)
- {
- cout<<" ";
- }
- cout<<h[j]<<endl;
- }
-
-
- if(s[r]==73)
- {
- break;
- _sleep(50);
- }
- }
- system("cls");
- for(int i=0;i<=3;i++)
- {
- if(s[i]==73)
- {
- cout<<"比賽結束! 由 "<<h[i]<<" 先馳得點!"<<endl;
- }
-
- }
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int x=0;x<4;x++)
- {
- for(int y=0;y<s[x];y++)
- {
- cout<<" ";
- }
- cout<<h[x]<<endl;
- }
- system("pause");
- round++;
- goto re;
- return 0;
- }
複製代碼 |