返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     int a=1;
  8.     re:
  9.     system("cls");
  10.     srand(time(NULL));
  11.     int s[]={0,0,0,0};  
  12.     string p[]={"◆","★","▲","●"};
  13.     int r=0;
  14.     cout<<"賽馬場 第"<<a<<"局"<<endl;
  15.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  16.     for(int i=0; i<4; i++)
  17.         cout<<p[i]<<endl;
  18.     system("pause");
  19.     system("cls");  
  20.     while(s[r]<=73)
  21.     {
  22.         r=rand()%4;   
  23.         s[r]++;
  24.         cout<<"比賽進行中"<<endl;
  25.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  26.         for(int i=0; i<4; i++)
  27.         {
  28.             for(int j=0; j<s[i]; j++)
  29.                 cout<<" ";
  30.             cout<<p[i]<<endl;
  31.         }
  32.         _sleep(50);
  33.         system("cls");
  34.     }

  35.     int max=0,win;
  36.     for(int i=0;i<=3;i++)
  37.     {
  38.             if(max<s[i])
  39.             {
  40.                     max=s[i];
  41.                     win=i;
  42.                 }
  43.     }
  44.       
  45.     cout<<"比賽結束!"<<endl;
  46.     cout<<"由"<<n[win]<<" 先抵達終點!"<<endl;
  47.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  48.     for(int i=0; i<4; i++)
  49.     {
  50.            
  51.         for(int j=0; j<s[i]; j++)
  52.             cout<<" ";
  53.         cout<<p[i]<<endl;
  54.     }
  55.     system("pause");
  56.     a++;
  57.     goto re;
  58.     return 0;
  59. }
複製代碼

TOP

返回列表