- #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 p[]={"○","€","§","◎"};
- srand(time(NULL));
- cout<<"賽馬場"<<endl;
- cout<<"------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<4; i++)
- {
- cout<<p[i]<<endl;
- }
- cout<<endl<<"可用餘額: "<<balance<<"元"<<endl<<endl;
- cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
- cin>>option;
- if(option==1){
-
- cout<<"買入: ";
- cin>>buy;
- balance=balance+buy;
- goto re;
- }
-
- system("pause");
- while(true)
- {
- system("cls");
- int r=rand()%4;
- s[r]++;
- cout<<"比賽"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
-
- for(int i=0; i<4; i++)
- {
-
- for(int j=0; j<s[i]; j++)
- cout<<" ";
- cout<<p[i]<<endl;
- }
- if(s[r]==73)
- break;
- _sleep(1);
- }
- system("cls");
- for(int i=0;i<=3;i++)
- {
- if(s[i]==73)
- {
- cout<<"比賽結束! 由 "<<p[i]<<" 先得點!"<<endl;
- }
- }
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
-
- for(int i=0; i<4; i++)
- {
-
- for(int j=0; j<s[i]; j++)
- cout<<" ";
- cout<<p[i]<<endl;
- }
-
-
- system("pause");
-
- goto re;
- return 0;
- }
複製代碼 |