返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.         int s[]={0,0,0,0};
  8.     string k[]={"◆","★","▲","●"};
  9.         int o, r, balance=0, option, buyin, bet, contestant;
  10.        
  11.        
  12.        
  13.         re:
  14.     o++;
  15.        
  16.         be:
  17.         system("cls");      
  18.     srand(time(NULL));
  19.    
  20.    
  21.         cout<<"「好事成雙」賽馬場 第"<<o<<"局"<<endl;
  22.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  23.     cout<<"◆"<<endl;
  24.     cout<<"★"<<endl;
  25.     cout<<"▲"<<endl;
  26.     cout<<"●"<<endl<<endl;


  27.         option=0;
  28.         cout<<"可用餘額: "<<balance<<"元"<<endl<<endl;
  29.         cout<<"<1>買入  <2>下注  <3>離開  請選擇: ";
  30.         cin>>option;
  31.        
  32.         if(option==1){
  33.                 cout<<"買入: ";
  34.                 cin>>buyin;
  35.                 if(buyin<=0){
  36.                         cout<<"輸入錯誤";
  37.                         _sleep(1500);
  38.                         goto be;
  39.                 }
  40.                 else{
  41.                 balance+=buyin;
  42.                 goto be;}
  43.         }
  44.         else if(option==2){
  45.                 cout<<"下注: ";
  46.                 cin>>bet;
  47.                 if(bet > balance){
  48.                         cout<<"餘額不足!!請買入"<<endl;
  49.                         _sleep(1500);
  50.                         goto be;
  51.                 }
  52.                 else if (bet>0 && bet<=balance){
  53.                         cout<<"<1>◆ <2>★ <3>▲ <4>● 請選擇: ";
  54.                         cin>>contestant;
  55.                 }
  56.                 else{
  57.                         cout<<"輸入錯誤";
  58.                         _sleep(1500);
  59.                         goto be;
  60.                 }               
  61.                
  62.         }
  63.        
  64.     else if(option==3){
  65.             goto end;
  66.         }
  67.     else{
  68.                 cout<<"輸入錯誤"<<endl;
  69.                 _sleep(1500);
  70.                 goto be;
  71.         }
  72.    
  73.    
  74.         system("pause");
  75.     while(true)
  76.     {
  77.         system("cls");
  78.         r=rand()%4;
  79.         s[r]++;   
  80.         cout<<"比賽進行中 第"<<o<<"局"<<endl;
  81.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  82.         for(int i=0; i<=s[0]; i++)
  83.             cout<<" ";
  84.         cout<<"◆"<<endl;
  85.         for(int i=0; i<=s[1]; i++)
  86.             cout<<" ";
  87.         cout<<"★"<<endl;
  88.         for(int i=0; i<=s[2]; i++)
  89.             cout<<" ";
  90.         cout<<"▲"<<endl;
  91.         for(int i=0; i<=s[3]; i++)
  92.             cout<<" ";
  93.         cout<<"●"<<endl;
  94.         if(s[r]==73)
  95.             break;
  96.         _sleep(50);                     
  97.     }
  98.    
  99.    
  100.         system("cls");
  101.     cout<<"比賽結束 由"<<k[r]<<"獲勝"<<endl;
  102.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  103.     for(int i=0; i<=s[0]; i++)
  104.         cout<<" ";
  105.     cout<<"◆"<<endl;
  106.     for(int i=0; i<=s[1]; i++)
  107.         cout<<" ";
  108.     cout<<"★"<<endl;
  109.     for(int i=0; i<=s[2]; i++)
  110.         cout<<" ";
  111.     cout<<"▲"<<endl;
  112.     for(int i=0; i<=s[3]; i++)
  113.         cout<<" ";
  114.     cout<<"●"<<endl;
  115.    
  116.     if(contestant - 1 == r){
  117.                 cout<<"你獲得"<<bet*3<<"元"<<endl;
  118.                 balance+=(bet*3);
  119.         }
  120.         else{
  121.                 cout<<"你輸了"<<bet<<"元"<<endl;
  122.                 balance-=bet;
  123.         }
  124.     cout<<"可用餘額: "<<balance<<"元"<<endl<<endl;
  125.         cout<<"<1>買入  <2>下注  <3>離開  請選擇: ";
  126.         cin>>option;
  127.        
  128.     system("pause");
  129.     goto re;
  130.    
  131.     end:
  132.             cout<<"Bye Bye";
  133.         return 0;
  134. }
複製代碼

TOP

返回列表