返回列表 發帖
本帖最後由 蔡沛倢 於 2023-7-7 20:40 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {   
  7.     int d=1;
  8.         re:
  9.     system("cls");
  10.     int a[]={0,0,0,0};
  11.     string e[]={"◆","★","▲","●"};
  12.     srand(time(NULL));
  13.     int b=0;
  14.     cout<<"****賽馬場-第"<<d<<"場****"<<endl;
  15.         cout<<"-------------------------------------------------------------------------|終點線"<<endl;
  16.         for(int i=0;i<=3;i++)
  17.     {
  18.        cout<<e[i]<<endl;
  19.     }
  20.         system("pause");
  21.     system("cls");
  22.         while(true)
  23.         {   
  24.             b=rand()%4;
  25.             a[b]++;
  26.                 cout<<"比賽進行中"<<endl;
  27.                 cout<<"-------------------------------------------------------------------------|終點線"<<endl;
  28.                
  29.                 for(int i=0;i<4;i++)
  30.                 {   
  31.             for(int j=0;j<=a[i];j++)
  32.             {
  33.                           cout<<" ";
  34.             }
  35.             cout<<e[i]<<endl;
  36.                 }
  37.                 if(a[b]==73)
  38.                 {
  39.                         break;
  40.                 }
  41.                 _sleep(50);
  42.                 system("cls");
  43.         }
  44.                 cout<<"!比賽結束 由"<<e[b]<<"勝利!"<<endl;
  45.                 cout<<"-------------------------------------------------------------------------|終點線"<<endl;
  46.                 for(int i=0;i<4;i++)
  47.                 {   
  48.             for(int j=0;j<=a[i];j++)
  49.             {
  50.                           cout<<" ";
  51.             }
  52.             cout<<e[i]<<endl;
  53.                 }
  54.                
  55.         system("pause");
  56.         d++;
  57.         goto re;
  58.     return 0;
  59. }
複製代碼

TOP

返回列表