- #include<iostream>
- #include<ctime>
- using namespace std;
- int main()
- {
- int balance=0;
- int round=1;
- re:
- system("cls");
- int s[]={0,0,0,0};
- string p[]={"◆", "★", "▲", "●"};
- int win;
- srand(time(NULL));
- cout<<"「好事成雙」賽馬場 第"<<round<<"局"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<4; i++)
- {
- cout<<p[i]<<endl;
- }
-
- int option;
- cout<<endl<<"可用餘額: "<<balance<<"元\n\n(1)儲值 (2)下注 (3)離開 請選擇: ";
- cin>>option;
- if(option==1){
- cout<<"儲多少: ";
- int buy;
- cin>>buy;
- balance+=buy;
- 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<<p[j]<<endl;
- }
-
- if(s[r]==73){
- win=r;
- break;
- }
-
- _sleep(5);
- }
- cout<<"比賽結束! 由 "<<p[win]<<" 先馳得點!"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
-
- for(int j=0; j<4; j++){
- for(int i=0; i<=s[j]; i++){
- cout<<" ";
- }
- cout<<p[j]<<endl;
- }
-
- system("pause");
- round++;
- goto re;
- return 0;
- }
複製代碼 |