返回列表 發帖
本帖最後由 張絜晰 於 2023-8-3 20:53 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.      int counter=0;
  8.     re:
  9.    counter++;
  10.     int s[]={0,0,0,0};
  11.     string h[]={"◆","★","▲","●"};
  12.     srand(time(NULL));
  13.    
  14.     system("cls");
  15.     cout<<"Racehorse thing: Round "<<counter<<endl;
  16.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  17.         for(int i=0;i<=3;i++){
  18.         cout<<h[i]<<endl;}
  19.     system("pause");
  20.     while(1)
  21.     {
  22.     system("cls");
  23.     int r=rand()%4;
  24.     s[r]++;
  25.     cout<<"Race in progress..."<<endl;
  26.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  27.    for(int i=0;i<=3;i++){
  28.            for(int j=0; j<=s[i];j++){
  29.                    cout<<" ";
  30.                    }
  31.         cout<<h[i]<<endl;
  32.         }
  33.     if(s[r]==73)
  34.                break;
  35.      _sleep(10);      
  36.     }
  37.      system("cls");
  38.      string win;
  39.     for (int i=0;i<=3; i++){
  40.         if (s[i]==73){
  41.                       win=h[i];}}
  42.     cout<<"Race ended! The winner was:"<<win<<endl;
  43.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  44.     for(int i=0;i<=3;i++){
  45.            for(int j=0; j<=s[i];j++){
  46.                    cout<<" ";
  47.                    }
  48.         cout<<h[i]<<endl;
  49.         }
  50.     system("pause");
  51.     goto re;
  52.     return 0;
  53. }
複製代碼
Attention Seeker </3

TOP

返回列表