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

TOP

返回列表