- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int counter=0;
- int m=0;
- re:
- counter++;
- int s[]={0,0,0,0};
- string h[]={"◆","★","▲","●"};
- srand(time(NULL));
-
- system("cls");
- cout<<"Racehorse thing: Round "<<counter<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0;i<=3;i++){
- cout<<h[i]<<endl;}
- cout<<"Your balance:"<<m<<endl;
- cout<<"Choose an action: (1)Buy more tokens (2)Place a bet (3) Leave "<<endl;
- int opt;
- cin>>opt;
- if(opt==1){
- int waste;
- cout<<"How much money do you want to spend?";
- cin>>waste;
- m=m+waste;
- goto re;
- }
-
- system("pause");
- while(1)
- {
- system("cls");
- int r=rand()%4;
- s[r]++;
- cout<<"Race in progress..."<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0;i<=3;i++){
- for(int j=0; j<=s[i];j++){
- cout<<" ";
- }
- cout<<h[i]<<endl;
- }
- if(s[r]==73)
- break;
- _sleep(10);
- }
- system("cls");
- string win;
- for (int i=0;i<=3; i++){
- if (s[i]==73){
- win=h[i];}}
- cout<<"Race ended! The winner was:"<<win<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0;i<=3;i++){
- for(int j=0; j<=s[i];j++){
- cout<<" ";
- }
- cout<<h[i]<<endl;
- }
- system("pause");
- goto re;
- return 0;
- }
複製代碼 |