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

  78.     system("pause");
  79.     return 0;
  80.       
  81. }
複製代碼

TOP

返回列表