返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.      int counter=0;
  8.      int m=0;
  9.     re:
  10.    counter++;
  11.     int s[]={0,0,0,0};
  12.     string h[]={"◆","★","▲","●"};
  13.     srand(time(NULL));
  14.    
  15.     system("cls");
  16.     cout<<"Racehorse thing: Round "<<counter<<endl;
  17.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  18.         for(int i=0;i<=3;i++){
  19.         cout<<h[i]<<endl;}
  20.         cout<<"Your balance:"<<m<<endl;
  21.         cout<<"Choose an action: (1)Buy more tokens (2)Place a bet (3) Leave "<<endl;
  22.         int opt;
  23.         cin>>opt;
  24.         if(opt==1){
  25.         int waste;
  26.         cout<<"How much money do you want to spend?";
  27.         cin>>waste;
  28.         m=m+waste;
  29.         goto re;
  30.         }
  31.         
  32.     system("pause");
  33.     while(1)
  34.     {
  35.     system("cls");
  36.     int r=rand()%4;
  37.     s[r]++;
  38.     cout<<"Race in progress..."<<endl;
  39.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  40.    for(int i=0;i<=3;i++){
  41.            for(int j=0; j<=s[i];j++){
  42.                    cout<<" ";
  43.                    }
  44.         cout<<h[i]<<endl;
  45.         }
  46.     if(s[r]==73)
  47.                break;
  48.      _sleep(10);      
  49.     }
  50.      system("cls");
  51.      string win;
  52.     for (int i=0;i<=3; i++){
  53.         if (s[i]==73){
  54.                       win=h[i];}}
  55.     cout<<"Race ended! The winner was:"<<win<<endl;
  56.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  57.     for(int i=0;i<=3;i++){
  58.            for(int j=0; j<=s[i];j++){
  59.                    cout<<" ";
  60.                    }
  61.         cout<<h[i]<<endl;
  62.         }
  63.     system("pause");
  64.     goto re;
  65.     return 0;
  66. }
複製代碼
Attention Seeker </3

TOP

返回列表