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

TOP

返回列表