返回列表 發帖
本帖最後由 楊炘樺 於 2025-4-25 18:24 編輯
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. string Players[4]={"◆","★","▲","●"};
  4. int Location[4]={0,0,0,0};
  5. void show()
  6. {
  7.     for(int i=0;i<37;i++)
  8.         cout<<"══";
  9.     cout<<"| 終點"<<endl;
  10.     for(int i=0;i<4;i++)
  11.     {
  12.         for(int j=0;j<Location[i];j++)
  13.             cout<<"  ";
  14.         cout<<Players[i]<<endl;
  15.     }
  16. }
  17. int main()
  18. {
  19.     while(true)
  20.     {
  21.         srand(time(NULL));
  22.         for(int i=0;i<4;i++)
  23.             Location[i]=0;
  24.         for(int i=0;i<27;i++)
  25.             cout<<' ';
  26.         cout<<"「好事成雙」賽馬場\n";
  27.         show();
  28.         cout<<"\n\n\n";
  29.         system("pause");
  30.         system("cls");
  31.         while(true)
  32.         {
  33.             for(int i=0;i<32;i++)
  34.             cout<<' ';
  35.             cout<<"比賽進行中\n";
  36.             Location[rand()%4]++;
  37.             show();
  38.             _sleep(300);
  39.             system("cls");
  40.             if(Location[0]==37 || Location[1]==37)
  41.                 break;
  42.             if(Location[2]==37 || Location[3]==37)
  43.                 break;
  44.         }
  45.         for(int i=0;i<30;i++)
  46.             cout<<' ';
  47.         cout<<"比賽結束\n";
  48.         show();
  49.         cout<<"\n\n\n";
  50.         system("pause");
  51.         system("cls");
  52.     }
  53.     return 0;
  54. }
複製代碼
六位參賽者:
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. string Players[6]={"◆","★","▲","●","▼","■"};
  4. int Location[6]={0,0,0,0,0,0};
  5. void show()
  6. {
  7.     for(int i=0;i<37;i++)
  8.         cout<<"══";
  9.     cout<<"| 終點"<<endl;
  10.     for(int i=0;i<6;i++)
  11.     {
  12.         for(int j=0;j<Location[i];j++)
  13.             cout<<"  ";
  14.         cout<<Players[i]<<endl;
  15.     }
  16. }
  17. int main()
  18. {
  19.     while(true)
  20.     {
  21.         srand(time(NULL));
  22.         for(int i=0;i<6;i++)
  23.             Location[i]=0;
  24.         for(int i=0;i<27;i++)
  25.             cout<<' ';
  26.         cout<<"「好事成雙」賽馬場\n";
  27.         show();
  28.         cout<<"\n\n\n";
  29.         system("pause");
  30.         system("cls");
  31.         while(true)
  32.         {
  33.             for(int i=0;i<32;i++)
  34.             cout<<' ';
  35.             cout<<"比賽進行中\n";
  36.             Location[rand()%6]++;
  37.             show();
  38.             _sleep(300);
  39.             system("cls");
  40.             if(Location[0]==37 || Location[1]==37 || Location[2]==37)
  41.                 break;
  42.             if(Location[3]==37 || Location[4]==37 || Location[5]==37)
  43.                 break;
  44.         }
  45.         for(int i=0;i<30;i++)
  46.             cout<<' ';
  47.         cout<<"比賽結束\n";
  48.         show();
  49.         cout<<"\n\n\n";
  50.         system("pause");
  51.         system("cls");
  52.     }
  53.     return 0;
  54. }
複製代碼

TOP

返回列表