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

TOP

返回列表