返回列表 發帖
  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.         system("cls");
  13.         cout<<"「好事成雙」賽馬場  "<<"第"<<times<<"次"<<endl;
  14.         cout<<"------------------------------------------------------------------------| 終點"<<endl;
  15.         cout<<"◆"<<endl;
  16.         cout<<"★"<<endl;
  17.         cout<<"▲"<<endl;
  18.         cout<<"●"<<endl;
  19.         system("pause");
  20.         system("cls");
  21.         while(horse1!=75 && horse2!=75 && horse3!=75 && horse4!=75)
  22.         {
  23.             random=rand()%4;   //產生0~3之隨機亂數
  24.             if(random==0)
  25.             {
  26.                 horse1++;
  27.             }
  28.             else if(random==1)
  29.             {
  30.                 horse2++;
  31.             }
  32.             else if(random==2)
  33.             {
  34.                 horse3++;
  35.             }
  36.             else if(random==3)
  37.             {
  38.                 horse4++;
  39.             }
  40.             cout<<"比賽進行中"<<endl;
  41.             cout<<"------------------------------------------------------------------------| 終點"<<endl;
  42.             for(int i=1; i<=horse1; i++)
  43.             {
  44.                 cout<<" ";
  45.             }
  46.             cout<<"◆"<<endl;
  47.             for(int i=1; i<=horse2; i++)
  48.             {
  49.                 cout<<" ";
  50.             }
  51.             cout<<"★"<<endl;
  52.             for(int i=1; i<=horse3; i++)
  53.             {
  54.                 cout<<" ";
  55.             }
  56.             cout<<"▲"<<endl;
  57.             for(int i=1; i<=horse4; i++)
  58.             {
  59.                 cout<<" ";
  60.             }
  61.             cout<<"●"<<endl;
  62.             system("cls");      
  63.         }
  64.         times++;
  65.         cout<<"比賽結束  由";
  66.         if(horse1==75)
  67.         {
  68.             cout<<"◆";              
  69.         }
  70.         if(horse2==75)
  71.         {
  72.             cout<<"★";              
  73.         }
  74.         if(horse3==75)
  75.         {
  76.             cout<<"▲";              
  77.         }
  78.         if(horse4==75)
  79.         {
  80.             cout<<"●";              
  81.         }
  82.         cout<<"先馳得點!"<<endl;
  83.         cout<<"------------------------------------------------------------------------| 終點"<<endl;
  84.         for(int i=1; i<=horse1; i++)
  85.         {
  86.             cout<<" ";
  87.         }
  88.         cout<<"◆"<<endl;
  89.         for(int i=1; i<=horse2; i++)
  90.         {
  91.             cout<<" ";
  92.         }
  93.         cout<<"★"<<endl;
  94.         for(int i=1; i<=horse3; i++)
  95.         {
  96.             cout<<" ";
  97.         }
  98.         cout<<"▲"<<endl;
  99.         for(int i=1; i<=horse4; i++)
  100.         {
  101.             cout<<" ";
  102.         }
  103.         cout<<"●"<<endl;
  104.         system("pause");
  105.         system("cls");      
  106.     }
  107.     system("pause");
  108.     return 0;   
  109. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<time.h>
  4. using namespace std;

  5. void Result(int horse1,int horse2,int horse3,int horse4)
  6. {
  7.        cout<<"------------------------------------------------------------------------| 終點"<<endl;
  8.         for(int i=1; i<=horse1; i++)
  9.         {
  10.             cout<<" ";
  11.         }
  12.         cout<<"◆"<<endl;
  13.         for(int i=1; i<=horse2; i++)
  14.         {
  15.             cout<<" ";
  16.         }
  17.         cout<<"★"<<endl;
  18.         for(int i=1; i<=horse3; i++)
  19.         {
  20.             cout<<" ";
  21.         }
  22.         cout<<"▲"<<endl;
  23.         for(int i=1; i<=horse4; i++)
  24.         {
  25.             cout<<" ";
  26.         }
  27.         cout<<"●"<<endl;      
  28. }

  29. int main()
  30. {
  31.     int times=1;
  32.     while(true)
  33.     {
  34.         int horse1=0, horse2=0, horse3=0, horse4=0,random=0;
  35.         srand(time(NULL));
  36.         system("cls");
  37.         cout<<"「好事成雙」賽馬場  "<<"第"<<times<<"次"<<endl;
  38.         cout<<"------------------------------------------------------------------------| 終點"<<endl;
  39.         cout<<"◆"<<endl;
  40.         cout<<"★"<<endl;
  41.         cout<<"▲"<<endl;
  42.         cout<<"●"<<endl;
  43.         system("pause");
  44.         system("cls");
  45.         while(horse1!=75 && horse2!=75 && horse3!=75 && horse4!=75)
  46.         {
  47.             random=rand()%4;   //產生0~3之隨機亂數
  48.             if(random==0)
  49.             {
  50.                 horse1++;
  51.             }
  52.             else if(random==1)
  53.             {
  54.                 horse2++;
  55.             }
  56.             else if(random==2)
  57.             {
  58.                 horse3++;
  59.             }
  60.             else if(random==3)
  61.             {
  62.                 horse4++;
  63.             }
  64.             cout<<"比賽進行中"<<endl;
  65.             Result(horse1,horse2,horse3,horse4);
  66.             system("cls");      
  67.         }
  68.         times++;
  69.         cout<<"比賽結束  由";
  70.         if(horse1==75)
  71.         {
  72.             cout<<"◆";              
  73.         }
  74.         if(horse2==75)
  75.         {
  76.             cout<<"★";              
  77.         }
  78.         if(horse3==75)
  79.         {
  80.             cout<<"▲";              
  81.         }
  82.         if(horse4==75)
  83.         {
  84.             cout<<"●";              
  85.         }
  86.         cout<<"先馳得點!"<<endl;
  87.         Result(horse1,horse2,horse3,horse4);
  88.         system("pause");
  89.         system("cls");      
  90.     }
  91.     system("pause");
  92.     return 0;   
  93. }
複製代碼

TOP

返回列表