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

TOP

返回列表