返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int h1=0;
  7.     int h2=0;
  8.     int h3=0;
  9.     int h4=0;
  10.     int random=0;
  11.     int round=1;
  12.     srand(time(NULL));
  13.     while(true)
  14.     {
  15.     cout<<"第"<<round<<"局"<<endl;
  16.     cout<<"「好事成雙」賽馬場"<<endl;
  17.     cout<<"|-------------------------------------------------------------------------|終點"<<endl;                                                                        
  18.     cout<<"◆"<<endl;
  19.     cout<<"★"<<endl;
  20.     cout<<"▲"<<endl;
  21.     cout<<"●"<<endl;
  22.     system("pause");
  23.     while(h1!=75&&h2!=75&&h3!=75&&h4!=75)
  24.     {
  25.         random=rand()%4;
  26.         if(random==0)
  27.         {
  28.             h1++;
  29.         }
  30.         if(random==1)
  31.         {
  32.             h2++;
  33.         }
  34.         if(random==2)
  35.         {
  36.             h3++;
  37.         }
  38.         if(random==3)
  39.         {
  40.             h4++;
  41.         }
  42.         cout<<"比賽進行中"<<endl;
  43.         cout<<"|-------------------------------------------------------------------------|終點"<<endl;
  44.         for(int i=0;i<=h1;i++)
  45.         {
  46.                 cout<<" ";
  47.         }
  48.         cout<<"◆"<<endl;
  49.         for(int i=0;i<=h2;i++)
  50.         {
  51.                 cout<<" ";
  52.         }
  53.         cout<<"★"<<endl;
  54.         for(int i=0;i<=h3;i++)
  55.         {
  56.                 cout<<" ";
  57.         }
  58.         cout<<"▲"<<endl;
  59.         for(int i=0;i<=h4;i++)
  60.         {
  61.                 cout<<" ";
  62.         }
  63.         cout<<"●"<<endl;
  64.         system("cls");
  65.     }
  66.     round++;
  67.     system("cls");
  68.     cout<<"比賽結束! 由";
  69.     if(h1==75)
  70.     {
  71.               cout<<"◆搶先得馳"<<endl;
  72.     }
  73.     if(h2==75)
  74.     {
  75.               cout<<"★搶先得馳"<<endl;
  76.     }
  77.     if(h3==75)
  78.     {
  79.               cout<<"▲搶先得馳"<<endl;
  80.     }
  81.     if(h4==75)
  82.     {
  83.               cout<<"●搶先得馳"<<endl;
  84.     }
  85.     }
  86.     system("pause");        
  87.     return 0;
  88. }
複製代碼

TOP

返回列表