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

TOP

返回列表