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

TOP

返回列表