返回列表 發帖

賽馬程式 (三)

1. 在比賽首頁顯示第幾局
2. 在比賽結束頁顯示哪一位選手勝出

附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<time.h>  
  4. using namespace std;
  5. int main()
  6. {
  7.     int times=0;
  8.     while(true)
  9.     {
  10.     int h1=0,h2=0,h3=0,h4=0,random=0,round=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(h1!=75&&h2!=75&&h3!=75&&h4!=75)
  20.     {
  21.        random=rand()%4;
  22.        if(random==0) {
  23.            h1++;
  24.         }  
  25.         else if(random==1)
  26.         {
  27.            h2++;
  28.         }
  29.         else if(random==2)
  30.         {
  31.            h3++;
  32.         }
  33.         else if(random==3)
  34.         {
  35.            h4++;
  36.         }
  37.          cout<<"比賽進行中"<<endl;
  38.          cout<<"---------------------------------------------------------------------[終點"<<endl;
  39.         for(int i=1; i<=h1; i++)
  40.         {
  41.            cout<<" ";
  42.         }   
  43.         cout<<"◆"<<endl;
  44.         
  45.         for(int i=1; i<=h2; i++)
  46.         {
  47.            cout<<" ";
  48.         }   
  49.         cout<<"★"<<endl;
  50.         
  51.          for(int i=1; i<=h3; i++) {
  52.            cout<<" ";
  53.         }   
  54.         cout<<"▲"<<endl;
  55.         
  56.          for(int i=1; i<=h4; i++) {
  57.            cout<<" ";
  58.         }   
  59.         
  60.         cout<<"●"<<endl;
  61.         system("cls");
  62.      }
  63.         times++;
  64.         system("cls");
  65.         if(h1==75)
  66.         {
  67.                   cout<<"比賽結束由◆先馳得點"<<endl;
  68.                  
  69.         }
  70.         if(h2==75)
  71.         {
  72.                   cout<<"比賽結束由★先馳得點"<<endl;
  73.                  
  74.         }
  75.         if(h3==75)
  76.         {
  77.                   cout<<"比賽結束由★先馳得點"<<endl;
  78.                   
  79.         }
  80.         if(h4==75)
  81.         {
  82.                   cout<<"比賽結束由●先馳得點"<<endl;
  83.                   
  84.         }     
  85. }
  86.     system("pause");
  87.     return 0;
  88.       
  89. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<time.h>
  4. using namespace std;
  5. int main()
  6. {
  7. re:
  8. int times=0;
  9. times++;
  10. while(true)      
  11. {
  12. int horse1=0,horse2=0,horse3=0,horse4=0;
  13. int random=0,num=0,num1=0,num2=0,num3=0;
  14. srand (time(NULL));
  15. system("cls");
  16. cout<<"☆★☆[嘉禾豬]賽馬場☆★☆"<<"          第"<<times<<"場"<<endl;
  17. cout<<"========================================================|終點"<<endl;
  18. cout<<"◆"<<endl;
  19. cout<<"★"<<endl;
  20. cout<<"☆"<<endl;
  21. cout<<"●"<<endl;
  22. cout<<"=============================================================="<<endl;
  23. cout<<"  ★☆★  遊戲規則  ★☆★  "<<endl;
  24. cout<<"1.下注正確將會獲得五倍的錢!"<<endl;
  25. cout<<"2.下注錯誤將會失去三倍的錢!"<<endl;
  26. cout<<"請下注 => 代碼和下注金額:100元~50000000元)(1)◆ (2)★ (3)☆ (4)●"<<endl;
  27. cout<<"代碼:";
  28. cin>>num;  
  29. if(num<1||num>4)
  30. {
  31. cout<<"代碼錯誤!"<<endl;
  32. system("pause");
  33. goto re;
  34. }
  35. cout<<"下注金額:";
  36. cin>>num1;

  37. if(num1<100||num1>50000000)
  38. {
  39. cout<<"金額錯誤!"<<endl;
  40. system("pause");
  41. goto re;
  42. }     
  43. cout<<"是否要反悔?  (1)要 (2)不要"<<endl;         
  44. cin>>num3;
  45. if(num3==1)
  46. {
  47. goto re;
  48. }
  49. else if(num3==2)
  50. {
  51. goto re5;
  52. }
  53.          re5:
  54.          system("pause");
  55.          system("cls");
  56.          while(horse1!=75||horse2!=75||horse3!=75||horse4!=75)
  57.      {
  58.          random=rand()%4;
  59.      if(random==0)
  60.      {
  61.          horse1++;
  62.      }
  63.          else if(random==1)
  64.      {
  65.          horse2++;
  66.      }
  67.          else if(random==2)
  68.      {
  69.          horse3++;
  70.      }
  71.          else if(random==3)
  72.          {
  73.          horse4++;
  74.      }
  75.          cout<<"比賽進行中"<<endl;
  76.          cout<<"========================================================|終點"<<endl;
  77.          for(int i=1;i<horse1;i++)
  78.      {
  79.      cout<<" ";                     
  80.      }cout<<"◆"<<endl;
  81.      for(int i=1;i<horse2;i++)
  82.      {
  83.      cout<<" ";                     
  84.      }cout<<"★"<<endl;
  85.      for(int i=1;i<horse3;i++)
  86.      {
  87.      cout<<" ";                     
  88.      }cout<<"☆"<<endl;     
  89.      for(int i=1;i<horse4;i++)
  90.      {
  91.      cout<<" ";                     
  92.      }cout<<"●"<<endl;   
  93.      system("cls");
  94.          if(horse1==60)
  95.          {         
  96.          cout<<"比賽結束"<<endl;
  97.          cout<<"==========================================================|終點"<<endl;
  98.          for(int i=1;i<horse1;i++)
  99.          {
  100.          cout<<" ";
  101.      }
  102.          cout<<"◆"<<endl;
  103.          for(int i=1;i<horse2;i++)
  104.          {
  105.          cout<<" ";
  106.      }
  107.          cout<<"★"<<endl;
  108.          for(int i=1;i<horse3;i++)
  109.          {
  110.          cout<<" ";
  111.      }
  112.          cout<<"☆"<<endl;
  113.          for(int i=1;i<horse4;i++)
  114.          {
  115.          cout<<" ";
  116.      }
  117.          cout<<"●"<<endl;
  118.          cout<<"==========================================================|===="<<endl;
  119.          cout<<"你輸入的代碼:("<<num<<")"<<endl;
  120.          cout<<"你下注了"<<num1<<"元"<<endl;
  121.          cout<<"(1)◆贏了!"<<endl;
  122.          if(num==1)
  123.          {
  124.          cout<<"恭喜你!你獲得了"<<num1*5<<"元"<<endl;
  125.          }
  126.          else if(num==2||num==3||num==4)
  127.          {
  128.          cout<<"真可惜!你失去了"<<num1*3<<"元"<<endl;
  129.          }
  130.          re1:
  131.          cout<<"要再玩一次嗎?  (1)要 (2)不要"<<endl;
  132.          cin>>num2;
  133.          if(num2==2)
  134.          {
  135.          system("cls");
  136.          cout<<"謝謝光臨!再見!"<<endl;
  137.          }
  138.          else if(num2==1)
  139.          {
  140.          times++;
  141.          break;
  142.          }
  143.          else if(num2<1||num2>2)
  144.          {
  145.          cout<<"輸入錯誤"<<endl;
  146.          goto re1;
  147.          }
  148.          system("pause");
  149.          if(num2==1)
  150.          {
  151.          continue;
  152.          }
  153.          else
  154.          {
  155.          break;
  156.          }
  157.          }
  158.          if(horse2==60)
  159.          {
  160.          cout<<"比賽結束"<<endl;
  161.          cout<<"==========================================================|終點"<<endl;
  162.          for(int i=1;i<horse1;i++)
  163.          {
  164.          cout<<" ";
  165.      }
  166.          cout<<"◆"<<endl;
  167.          for(int i=1;i<horse2;i++)
  168.          {
  169.          cout<<" ";
  170.      }
  171.          cout<<"★"<<endl;
  172.          for(int i=1;i<horse3;i++)
  173.          {
  174.          cout<<" ";
  175.      }
  176.          cout<<"☆"<<endl;
  177.          for(int i=1;i<horse4;i++)
  178.          {
  179.          cout<<" ";
  180.      }
  181.          cout<<"●"<<endl;
  182.          cout<<"==========================================================|===="<<endl;
  183.          cout<<"你輸入的代碼:("<<num<<")"<<endl;
  184.          cout<<"你下注了"<<num1<<"元"<<endl;
  185.          cout<<"(2)★贏了!"<<endl;
  186.          if(num==2)
  187.          {
  188.          cout<<"恭喜你!你獲得了"<<num1*5<<"元"<<endl;
  189.          }
  190.          else if(num==1||num==3||num==4)
  191.          {
  192.          cout<<"真可惜!你失去了"<<num1*3<<"元"<<endl;
  193.          }
  194.          re2:
  195.          cout<<"要再玩一次嗎? (1)要  (2)不要"<<endl;
  196.          cin>>num2;
  197.          if(num2==2)
  198.          {
  199.          system("cls");
  200.          cout<<"謝謝光臨!再見!"<<endl;
  201.          }
  202.          else if(num2==1)
  203.          {
  204.          times++;
  205.          break;
  206.          }
  207.          else if(num2<1||num2>2)
  208.          {
  209.          cout<<"輸入錯誤"<<endl;
  210.          goto re2;
  211.          }
  212.          system("pause");
  213.          if(num2==1)
  214.          {
  215.          continue;
  216.          }
  217.          else
  218.          {
  219.          break;
  220.          }
  221.          }
  222.          if(horse3==60)
  223.          {
  224.          cout<<"比賽結束"<<endl;
  225.          cout<<"==========================================================|終點"<<endl;
  226.          for(int i=1;i<horse1;i++)
  227.          {
  228.          cout<<" ";
  229.      }
  230.          cout<<"◆"<<endl;
  231.          for(int i=1;i<horse2;i++)
  232.          {
  233.          cout<<" ";
  234.      }
  235.          cout<<"★"<<endl;
  236.          for(int i=1;i<horse3;i++)
  237.          {
  238.          cout<<" ";
  239.      }
  240.          cout<<"☆"<<endl;
  241.          for(int i=1;i<horse4;i++)
  242.          {
  243.          cout<<" ";
  244.      }
  245.          cout<<"●"<<endl;
  246.          cout<<"==========================================================|===="<<endl;
  247.          cout<<"你輸入的代碼:("<<num<<")"<<endl;
  248.          cout<<"你下注了"<<num1<<"元"<<endl;
  249.          cout<<"(3)☆贏了!"<<endl;
  250.          if(num==3)
  251.          {
  252.          cout<<"恭喜你!你獲得了"<<num1*5<<"元"<<endl;
  253.          }
  254.          else if(num==1||num==2||num==4)
  255.          {
  256.          cout<<"真可惜!你失去了"<<num1*3<<"元"<<endl;
  257.          }
  258.          re3:
  259.          cout<<"要再玩一次嗎?  (1)要 (2)不要"<<endl;
  260.          cin>>num2;
  261.          if(num2==2)
  262.          {
  263.          system("cls");
  264.          cout<<"謝謝光臨!再見!"<<endl;
  265.          }
  266.          else if(num2==1)
  267.          {
  268.          times++;
  269.          break;
  270.          }
  271.          else if(num2<1||num2>2)
  272.          {
  273.          cout<<"輸入錯誤"<<endl;
  274.          goto re3;
  275.          }
  276.          system("pause");
  277.          if(num2==1)
  278.          {
  279.          continue;
  280.          }
  281.          else
  282.          {
  283.          break;
  284.          }
  285.          }
  286.          if(horse4==60)
  287.          {
  288.          cout<<"比賽結束"<<endl;
  289.          cout<<"==========================================================|終點"<<endl;
  290.          for(int i=1;i<horse1;i++)
  291.          {
  292.          cout<<" ";
  293.      }
  294.          cout<<"◆"<<endl;
  295.          for(int i=1;i<horse2;i++)
  296.          {
  297.          cout<<" ";
  298.      }
  299.          cout<<"★"<<endl;
  300.          for(int i=1;i<horse3;i++)
  301.          {
  302.          cout<<" ";
  303.      }
  304.          cout<<"☆"<<endl;
  305.          for(int i=1;i<horse4;i++)
  306.          {
  307.          cout<<" ";
  308.      }
  309.          cout<<"●"<<endl;
  310.          cout<<"==========================================================|===="<<endl;
  311.          cout<<"你輸入的代碼:("<<num<<")"<<endl;
  312.          cout<<"你下注了"<<num1<<"元"<<endl;
  313.          cout<<"(4)●贏了!"<<endl;
  314.          if(num==4)
  315.          {
  316.          cout<<"恭喜你!你獲得了"<<num1*5<<"元"<<endl;
  317.          }
  318.          else if(num==1||num==2||num==3)
  319.          {
  320.          cout<<"真可惜!你失去了"<<num1*3<<"元"<<endl;
  321.          }
  322.          re4:
  323.          cout<<"要再玩一次嗎?  (1)要 (2)不要"<<endl;
  324.          cin>>num2;
  325.          if(num2==2)
  326.          {
  327.          system("cls");
  328.          cout<<"謝謝光臨!再見!"<<endl;
  329.          }
  330.          else if(num2==1)
  331.          {
  332.          times++;
  333.          break;
  334.          }
  335.          else if(num2<1||num2>2)
  336.          {
  337.          cout<<"輸入錯誤"<<endl;
  338.          goto re4;
  339.          }
  340.          system("pause");
  341.          if(num2==1)
  342.          {
  343.          continue;
  344.          }
  345.          else
  346.          {
  347.          times++;
  348.          break;
  349.          }
  350.          }
  351.   if(num2==2)
  352.   {
  353.   break;
  354.   }
  355.   }
  356. if(num2==2)
  357. {
  358. break;
  359. }
  360. }
  361. return 0;
  362. }
複製代碼

TOP

  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

  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

  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

  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

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

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int h1=0;
  7.     int h2=0;
  8.     int h3=0;
  9.     int h4=0;
  10.     int random=0;
  11.     int round=1;
  12.     srand(time(NULL));
  13.     while(true)
  14.     {
  15.     cout<<"第"<<round<<"局"<<endl;
  16.     cout<<"「好事成雙」賽馬場"<<endl;
  17.     cout<<"|-------------------------------------------------------------------------|終點"<<endl;                                                                        
  18.     cout<<"◆"<<endl;
  19.     cout<<"★"<<endl;
  20.     cout<<"▲"<<endl;
  21.     cout<<"●"<<endl;
  22.     cout<<"(1)下注\t\t(2)錢包\t\t(3)";
  23.     system("pause");
  24.     while(h1!=75&&h2!=75&&h3!=75&&h4!=75)
  25.     {
  26.         random=rand()%4;
  27.         if(random==0)
  28.         {
  29.             h1++;
  30.         }
  31.         if(random==1)
  32.         {
  33.             h2++;
  34.         }
  35.         if(random==2)
  36.         {
  37.             h3++;
  38.         }
  39.         if(random==3)
  40.         {
  41.             h4++;
  42.         }
  43.         cout<<"比賽進行中"<<endl;
  44.         cout<<"|-------------------------------------------------------------------------|終點"<<endl;
  45.         for(int i=0;i<=h1;i++)
  46.         {
  47.                 cout<<" ";
  48.         }
  49.         cout<<"◆"<<endl;
  50.         for(int i=0;i<=h2;i++)
  51.         {
  52.                 cout<<" ";
  53.         }
  54.         cout<<"★"<<endl;
  55.         for(int i=0;i<=h3;i++)
  56.         {
  57.                 cout<<" ";
  58.         }
  59.         cout<<"▲"<<endl;
  60.         for(int i=0;i<=h4;i++)
  61.         {
  62.                 cout<<" ";
  63.         }
  64.         cout<<"●"<<endl;
  65.         system("cls");
  66.     }
  67.     round++;
  68.     system("cls");
  69.     cout<<"比賽結束! 由";
  70.     if(h1==75)
  71.     {
  72.               cout<<"◆搶先得馳"<<endl;
  73.     }
  74.     if(h2==75)
  75.     {
  76.               cout<<"★搶先得馳"<<endl;
  77.     }
  78.     if(h3==75)
  79.     {
  80.               cout<<"▲搶先得馳"<<endl;
  81.     }
  82.     if(h4==75)
  83.     {
  84.               cout<<"●搶先得馳"<<endl;
  85.     }
  86.     }
  87.     system("pause");        
  88.     return 0;
  89. }
複製代碼

TOP

返回列表