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

  135.     system("pause");
  136.     return 0;
  137.       
  138. }
複製代碼

TOP

返回列表