返回列表 發帖
  1. {:3_41:}
複製代碼
  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;  
  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.       else if(option == 2)
  37.       {
  38.          cout<<"下注: ";
  39.          cin>>bet;  
  40.          cout<<endl<<"(1)◆ (2)★ (3)▲ (4)●  請選擇: ";
  41.          cin>>player;
  42.          cout<<"比賽即將開始..."<<endl<<endl;   
  43.       }
  44.       else if(option == 3)
  45.       {
  46.          break;
  47.       }
  48.       system("pause");
  49.       system("cls");
  50.       
  51.       while(horse1!=75 && horse2!=75 && horse3!=75 && horse4!=75)
  52.       {
  53.          
  54.         random=rand()%4;   
  55.         if(random==0) {
  56.            horse1++;
  57.         }  
  58.         else if(random==1) {
  59.            horse2++;
  60.         }
  61.         else if(random==2) {
  62.            horse3++;
  63.         }
  64.         else if(random==3) {
  65.            horse4++;
  66.         }
  67.         cout<<"比賽進行中"<<endl;
  68.         cout<<"------------------------------------------------------------------------| 終點"<<endl;
  69.       
  70.         for(int i=1; i<=horse1; i++) {
  71.            cout<<" ";
  72.         }   
  73.         cout<<"◆"<<endl;
  74.         
  75.         for(int i=1; i<=horse2; i++) {
  76.            cout<<" ";
  77.         }   
  78.         cout<<"★"<<endl;
  79.         
  80.          for(int i=1; i<=horse3; i++) {
  81.            cout<<" ";
  82.         }   
  83.         cout<<"▲"<<endl;
  84.         
  85.          for(int i=1; i<=horse4; i++) {
  86.            cout<<" ";
  87.         }   
  88.         cout<<"●"<<endl;
  89.         system("cls");      
  90.     }
  91.     times++;
  92.     system("cls");     
  93.     cout<<"比賽結束! 由 ";
  94.     if(horse1 == 75) {
  95.       cout<< "◆" << "先馳得點" << endl;      
  96.     }
  97.     else if (horse2 == 75) {
  98.       cout<< "★" << "先馳得點" << endl;      
  99.     }
  100.     else if (horse3 == 75) {
  101.       cout<< "▲" << "先馳得點" << endl;      
  102.     }
  103.     else if (horse4 == 75) {
  104.       cout<< "●" << "先馳得點" << endl;      
  105.     }
  106.      
  107.       cout<<"------------------------------------------------------------------------| 終點"<<endl;
  108.       
  109.         for(int i=1; i<=horse1; i++) {
  110.            cout<<" ";
  111.         }   
  112.         cout<<"◆"<<endl;
  113.         
  114.         for(int i=1; i<=horse2; i++) {
  115.            cout<<" ";
  116.         }   
  117.         cout<<"★"<<endl;
  118.         
  119.          for(int i=1; i<=horse3; i++) {
  120.            cout<<" ";
  121.         }   
  122.         cout<<"▲"<<endl;
  123.         
  124.          for(int i=1; i<=horse4; i++) {
  125.            cout<<" ";
  126.         }   
  127.         cout<<"●"<<endl;
  128.         system("pause");
  129.         }
  130.     }

  131.     system("pause");
  132.     return 0;
  133.       
  134. }
複製代碼

TOP

返回列表