返回列表 發帖
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <time.h>
  4. using namespace std;
  5. int main()
  6. {     
  7.     int h1=0,h2=0,h3=0,h4=0;
  8.     srand(time(NULL));
  9.     int random=0;
  10.     cout<<"「賽馬場」"<<endl;
  11.     cout<<"|--------------------------------------------------------------------------|終點"<<endl;
  12.     cout<<"0"<<endl;
  13.     cout<<"1"<<endl;
  14.     cout<<"2"<<endl;
  15.     cout<<"3"<<endl;
  16.     while(houres1!=75 && houres2!=75 && houres3!=75 && houres4!=75)
  17.     { random=rand()%4;
  18.        if(random==0)
  19.        {  houres1++;      
  20.        }
  21.        else if(random==1)
  22.        { houres2++;      
  23.        }
  24.        else if(random==2)
  25.        {  houres3++;
  26.        }
  27.        else if(random==3)
  28.        {  houres4++;
  29.        }
  30.        cout<<"比賽開始"<<endl;
  31.        cout<<"|----------------------------------------------------------------------------|終點"<<endl;
  32.        for(int i=1; i<=h1; i++)
  33.        {
  34.            cout<<" ";
  35.         }   
  36.         cout<<"2"<<endl;
  37.          for(int i=1; i<=h2; i++)
  38.        {
  39.            cout<<" ";
  40.         }   
  41.         cout<<"3"<<endl;
  42.          for(int i=1; i<=h3; i++)
  43.        {
  44.            cout<<" ";
  45.         }   
  46.         cout<<"4"<<endl;
  47.          for(int i=1; i<=h4; i++)
  48.        {
  49.            cout<<" ";
  50.         }   
  51.         cout<<"3"<<endl;
  52.        system("cls");
  53.          
  54.     }
  55.     system("pause");
  56.     return 0;
  57. }
複製代碼

TOP

返回列表