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