返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n=1, winner, balance=0, option, buyin, bet, player;
  7.     srand(time(NULL));
  8.     re:
  9.     system("cls");      
  10.     int s[]={0,0,0,0};
  11.     cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<endl;
  12.     cout<<"-   -   -   -   -   -   -   -   -   -   -   終點"<<endl;
  13.     cout<<"1"<<endl;
  14.     cout<<"2"<<endl;
  15.     cout<<"3"<<endl;
  16.     cout<<"4"<<endl;
  17.     cout<<endl<<"可用餘額: "<<balance<<" 元"<<endl<<endl;
  18.     cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
  19.     cin>>option;
  20.     if(option==1)
  21.     {
  22.         cout<<"買入: ";
  23.         cin>>buyin;
  24.         if(buyin<=0)
  25.         {
  26.              cout<<"輸入錯誤!";
  27.              _sleep(1500);
  28.              goto re;     
  29.         }
  30.         balance+=buyin;
  31.         goto re;         
  32.     }
  33.     else if(option==2)
  34.     {
  35.         cout<<"下注: ";
  36.         cin>>bet;
  37.         if(bet<=0)
  38.         {
  39.              cout<<"輸入錯誤!";
  40.              _sleep(1500);
  41.              goto re;     
  42.         }
  43.         if(bet>balance)
  44.         {
  45.              cout<<"可用餘額不足,請先買入!";
  46.              _sleep(1500);
  47.              goto re;     
  48.         }
  49.         cout<<endl<<"1號  2號  3號  4號  請選擇: ";
  50.         cin>>player;
  51.         cout<<"比賽即將開始..."<<endl<<endl;         
  52.     }
  53.     else if(option==3)
  54.     {
  55.         goto end;         
  56.     }
  57.     else
  58.     {
  59.         cout<<"輸入錯誤!";
  60.         _sleep(1500);
  61.         goto re;
  62.     }
  63.     system("pause");
  64.     while(true)
  65.     {
  66.         system("cls");
  67.         int r=rand()%4;   //0~3
  68.         s[r]++;   
  69.         cout<<"比賽進行中"<<endl;
  70.         cout<<"-   -   -   -   -   -   -   -   -   -   -   終點"<<endl;
  71.         for(int i=0; i<=s[0]; i++)
  72.             cout<<" ";
  73.         cout<<"1"<<endl;
  74.         for(int i=0; i<=s[1]; i++)
  75.             cout<<" ";
  76.         cout<<"2"<<endl;
  77.         for(int i=0; i<=s[2]; i++)
  78.             cout<<" ";
  79.         cout<<"3"<<endl;
  80.         for(int i=0; i<=s[3]; i++)
  81.             cout<<" ";
  82.         cout<<"4"<<endl;
  83.         if(s[r]==45)
  84.         {
  85.             winner=r+1;
  86.             break;
  87.         }
  88.         _sleep(60);                     
  89.     }
  90.     system("cls");
  91.     cout<<"比賽結束! 由 "<<winner<<" 號選手先馳得點!"<<endl;
  92.     cout<<"-   -   -   -   -   -   -   -   -   -   -   終點"<<endl;
  93.     for(int i=0; i<=s[0]; i++)
  94.         cout<<" ";
  95.     cout<<"1"<<endl;
  96.     for(int i=0; i<=s[1]; i++)
  97.         cout<<" ";
  98.     cout<<"2"<<endl;
  99.     for(int i=0; i<=s[2]; i++)
  100.         cout<<" ";
  101.     cout<<"3"<<endl;
  102.     for(int i=0; i<=s[3]; i++)
  103.         cout<<" ";
  104.     cout<<"4"<<endl;
  105.     n++;
  106.     if(winner=player)
  107.     {
  108.       cout<<"贏了"<<bet*3<<"元"<<endl;
  109.       balance+=bet*3;
  110.       
  111.     }
  112.     else
  113.     {
  114.       cout<<"損失"<<bet<<"元"<<endl;
  115.       balance-=bet;
  116.     }
  117.     if(balance==0)
  118.     cout<<"沒輸沒贏!全身而退!"<<endl;
  119.     else if(balance>0)
  120.     cout<<"恭喜你!總共賺進"<<balance<<"元!"<<endl;
  121.     else
  122.     cout<<"不好意思!總共損失了"<<-balance<<"元!"<<endl;
  123.     cout<<"謝謝光臨!下次再來!"<<endl;
  124.     system("pause");
  125.     goto re;
  126.    
  127.    
  128.     end:
  129.     cout<<endl<<"慢走!"<<endl;
  130.     _sleep(1500);
  131.     return 0;
  132. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n=1, winner, balance=0, option, buyin, bet, player,wallet=0;
  7.       srand(time(NULL));
  8.       re:
  9.       system("cls");      
  10.     int s[]={0,0,0,0};
  11.       cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<endl;
  12.       cout<<"-   -   -   -   -   -   -   -   -   -   -   -  終點"<<endl;
  13.       cout<<"1"<<endl;
  14.       cout<<"2"<<endl;
  15.       cout<<"3"<<endl;
  16.       cout<<"4"<<endl;
  17.       cout<<endl<<"可用餘額: "<<balance<<" 元"<<endl<<endl;
  18.       cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
  19.       cin>>option;
  20.     if(option==1)
  21.     {
  22.         cout<<"買入: ";
  23.         cin>>buyin;
  24.         if(buyin<=0)
  25.         {
  26.              cout<<"輸入錯誤!";
  27.              _sleep(1500);
  28.              goto re;     
  29.         }
  30.         balance+=buyin;
  31.         goto re;         
  32.     }
  33.     else if(option==2)
  34.     {
  35.         cout<<"下注: ";
  36.         cin>>bet;
  37.         if(bet<=0)
  38.         {
  39.              cout<<"輸入錯誤!";
  40.              _sleep(1500);
  41.              goto re;     
  42.         }
  43.         if(bet>balance)
  44.         {
  45.              cout<<"可用餘額不足,請先買入!";
  46.              _sleep(1500);
  47.              goto re;     
  48.         }
  49.         cout<<endl<<"1號  2號  3號  4號  請選擇: ";
  50.         cin>>player;
  51.         cout<<"比賽即將開始..."<<endl<<endl;         
  52.     }
  53.     else if(option==3)
  54.     {
  55.         goto end;         
  56.     }
  57.     else
  58.     {
  59.         cout<<"輸入錯誤!";
  60.         _sleep(1500);
  61.         goto re;
  62.     }
  63.       system("pause");
  64.     while(true)
  65.     {
  66.         system("cls");
  67.         int r=rand()%4;   
  68.         s[r]++;   
  69.         cout<<"比賽進行中"<<endl;
  70.         cout<<"-   -   -   -   -   -   -   -   -   -   -   -  終點"<<endl;
  71.         for(int i=0; i<=s[0]; i++)
  72.             cout<<" ";
  73.         cout<<"1"<<endl;
  74.         for(int i=0; i<=s[1]; i++)
  75.             cout<<" ";
  76.         cout<<"2"<<endl;
  77.         for(int i=0; i<=s[2]; i++)
  78.             cout<<" ";
  79.         cout<<"3"<<endl;
  80.         for(int i=0; i<=s[3]; i++)
  81.             cout<<" ";
  82.         cout<<"4"<<endl;
  83.         if(s[r]==45)
  84.         {
  85.             winner=r+1;
  86.             break;
  87.         }
  88.         _sleep(60);                     
  89.     }
  90.     system("cls");
  91.       cout<<"比賽結束! 由 "<<winner<<" 號選手先馳得點!"<<endl;
  92.       cout<<"-   -   -   -   -   -   -   -   -   -   -   -  終點"<<endl;
  93.     for(int i=0; i<=s[0]; i++)
  94.         cout<<" ";
  95.     cout<<"1"<<endl;
  96.     for(int i=0; i<=s[1]; i++)
  97.         cout<<" ";
  98.     cout<<"2"<<endl;
  99.     for(int i=0; i<=s[2]; i++)
  100.         cout<<" ";
  101.     cout<<"3"<<endl;
  102.     for(int i=0; i<=s[3]; i++)
  103.         cout<<" ";
  104.       cout<<"4"<<endl;
  105.       n++;
  106.     if(winner==player)
  107.     {
  108.       cout<<"贏了"<<bet*3<<"元"<<endl;
  109.       balance+=bet*3;
  110.       wallet+=bet*3;
  111.     }
  112.     else
  113.     {
  114.       cout<<"損失"<<bet<<"元"<<endl;
  115.       balance-=bet;
  116.       wallet-=bet;
  117.     }
  118.     system("pause");
  119.       goto re;
  120.      
  121.    
  122.     end:
  123.     if(wallet==0)
  124.       cout<<"沒輸沒贏!全身而退!"<<endl;
  125.     else if(wallet>0)
  126.       cout<<"恭喜你!總共賺進"<<wallet<<"元!"<<endl;
  127.     else
  128.       cout<<"不好意思!總共損失了"<<-wallet<<"元!"<<endl;
  129.       cout<<"謝謝光臨!下次再來!"<<endl;
  130.       system("pause");
  131.    
  132.    
  133.     return 0;
  134. }
複製代碼

TOP

返回列表