返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     int round=1;
  8.     system("cls");      
  9.    
  10.         string h[]={"◆","★","▲","●"};     
  11.     srand(time(NULL));
  12.         re:
  13.                 int s[]={0,0,0,0};
  14.                 system("cls");
  15.     cout<<"「好事成雙」賽馬場,第"<<round<<"局"<<endl;
  16.     cout<<"------------------------------------------------------------------------------------------------------------------| 終點"<<endl;
  17.     for(int i=0;i<=3;i++)
  18.     {
  19.             cout<<h[i]<<endl;
  20.         }
  21.         cout<<"按enter開始  1.一般 2.快速"<<endl;
  22.         int option;
  23.         cin>>option;
  24.        
  25.         system("pause");
  26.     while(true)
  27.     {
  28.         system("cls");   
  29.         int r=rand()%4;   
  30.         
  31.         cout<<"比賽進行中"<<endl;
  32.         cout<<"------------------------------------------------------------------------------------------------------------------| 終點"<<endl;
  33.         if(option==1)
  34.         {
  35.                 s[r]++;
  36.                 for(int j=0; j<=3; j++)
  37.                         {
  38.                         for(int i=0; i<=s[j]; i++)
  39.                             cout<<" ";
  40.                         cout<<h[j]<<endl;
  41.                         }
  42.                         if(s[r]==112)
  43.                     break;
  44.                 _sleep(50);   
  45.                 }
  46.                 else if(option==2)
  47.                 {
  48.                         s[r]+=8;
  49.                         for(int j=0; j<=3; j++)
  50.                         {
  51.                         for(int i=0; i<=s[j]; i++)
  52.                             cout<<" ";
  53.                         cout<<h[j]<<endl;
  54.                         }
  55.                         if(s[r]>=112)
  56.                     break;
  57.                 _sleep(100);   
  58.                 }
  59.         
  60.                                  
  61.     }
  62.     system("cls");
  63.     cout<<"比賽結束,";
  64.     for(int i=0;i<=3;i++)
  65.     {
  66.             if(s[i]>=112)
  67.                 {
  68.                         cout<<h[i]<<"贏了"<<endl;
  69.                         break;
  70.                 }
  71.         }
  72.     cout<<"------------------------------------------------------------------------------------------------------------------| 終點"<<endl;
  73.     for(int j=0; j<=3; j++)
  74.                 {
  75.                 for(int i=0; i<=s[j]; i++)
  76.             cout<<" ";
  77.         cout<<h[j]<<endl;
  78.                 }
  79.         round++;       
  80.     system("pause");
  81.     goto re;
  82.     return 0;
  83. }
複製代碼

TOP

返回列表