返回列表 發帖
  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 horse1=0, horse2=0, horse3=0, horse4=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.    
  21.     while(horse1!=75 && horse2!=75 && horse3!=75 && horse4!=75)
  22.     {
  23.         random=rand()%4;  
  24.         if(random==0) {
  25.            horse1++;
  26.         }  
  27.         else if(random==1) {
  28.            horse2++;
  29.         }
  30.         else if(random==2) {
  31.            horse3++;
  32.         }
  33.         else if(random==3) {
  34.            horse4++;
  35.         }
  36.         cout<<"比賽進行中"<<endl;
  37.         cout<<"------------------------------------------------------------------------| 終點"<<endl;
  38.       
  39.         for(int i=1; i<=horse1; i++) {
  40.            cout<<" ";
  41.         }   
  42.         cout<<"◆"<<endl;
  43.         
  44.         for(int i=1; i<=horse2; i++) {
  45.           cout<<" ";
  46.         }   
  47.         cout<<"★"<<endl;
  48.         
  49.          for(int i=1; i<=horse3; i++) {
  50.            cout<<" ";
  51.         }   
  52.         cout<<"▲"<<endl;
  53.         
  54.          for(int i=1; i<=horse4; i++) {
  55.            cout<<" ";
  56.         }  
  57.         cout<<"●"<<endl;
  58.         system("cls");
  59.     }
  60.     system("cls");
  61.     cout<<"比賽結束,由:";
  62.     if(horse1==75)
  63.     {
  64.     cout<<"◆搶先得馳"<<endl;
  65.      }
  66.     else  if(horse2==75)
  67.      {
  68.     cout<<"★搶先得馳"<<endl;
  69.       }
  70.      else if(horse3==75)
  71.     {
  72.     cout<<"●搶先得馳"<<endl;
  73.     }
  74.      else if(horse4==75)
  75.     {
  76.     cout<<"◆搶先得馳"<<endl;
  77.     }
  78.      
  79.      times++;   
  80.     }
  81.     system("pause");
  82.     return 0;     
  83. }
複製代碼

TOP

返回列表