返回列表 發帖

賽馬程式 (七)

完成選項 (3)離開 的相對應程式碼
在離開時顯示戰果, 譬如:
"沒輸沒贏! 全身而退!"
"恭喜你! 這次總共贏了100元!"
"不好意思! 讓你損失了200元!"
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n=1,balance=0,winner,money=0;
  7.     re1:
  8.     int a=0, b=0, c=0, d=0, r, option, buyin, bet;
  9.     system("cls");
  10.     cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<endl;
  11.     cout<<"------------------------------------------------------------------------| 終點"<<endl;
  12.     cout<<"◆"<<endl;
  13.     cout<<"★"<<endl;
  14.     cout<<"▲"<<endl;
  15.     cout<<"●"<<endl;
  16.     cout<<endl;
  17.     cout<<"可用餘額: "<<balance<<"元"<<endl<<endl;
  18.     cout<<"(1)買入  (2)下注  (3)離開  請選擇: ";
  19.     cin>>option;
  20.     if(option==1)
  21.     {
  22.         cout<<"買入: ";
  23.         cin>>buyin;
  24.         balance+=buyin;   //balance=balance+buyin
  25.         goto re1;
  26.     }else if(option==2)
  27.     {
  28.         if(balance==0)
  29.         {
  30.             cout<<"可用餘額不足! 請先買入!"<<endl<<endl;
  31.             system("pause");
  32.             goto re1;
  33.         }
  34.         cout<<"下注: ";
  35.         cin>>bet;
  36.         if(bet>balance)
  37.         {
  38.             cout<<"可用餘額不足! 請先買入!"<<endl<<endl;
  39.             system("pause");
  40.             goto re1;   
  41.         }else
  42.         {
  43.             cout<<endl<<"(1)◆ (2)★ (3)▲ (4)●  請選擇: ";
  44.             cin>>option;
  45.             cout<<"比賽即將開始..."<<endl<<endl;
  46.             system("pause");   
  47.         }  
  48.     }else if(option==3)
  49.     {
  50.         goto end;  
  51.     }else
  52.     {
  53.         cout<<"輸入錯誤!"<<endl;
  54.         system("pause");
  55.         goto re1;
  56.     }
  57.     system("cls");
  58.     srand(time(NULL));
  59.     while(a!=75 && b!=75 && c!=75 && d!=75)
  60.     {
  61.         r=rand()%4;   //產生0~3之隨機亂數
  62.         if(r==0)
  63.             a++;
  64.         else if(r==1)
  65.             b++;
  66.         else if(r==2)
  67.             c++;
  68.         else
  69.             d++;
  70.         cout<<"比賽進行中"<<endl;
  71.         cout<<"------------------------------------------------------------------------| 終點"<<endl;
  72.         for(int i=1; i<=a; i++)
  73.             cout<<" ";
  74.         cout<<"◆"<<endl;
  75.         for(int i=1; i<=b; i++)
  76.             cout<<" ";
  77.         cout<<"★"<<endl;
  78.         for(int i=1; i<=c; i++)
  79.             cout<<" ";
  80.         cout<<"▲"<<endl;
  81.         for(int i=1; i<=d; i++)
  82.             cout<<" ";
  83.         cout<<"●"<<endl;   
  84.         system("cls");      
  85.     }
  86.     cout<<"比賽結束! 由 ";
  87.     if(a==75)
  88.     {
  89.         cout<<"◆";
  90.         winner=1;
  91.     }
  92.     else if(b==75)
  93.     {
  94.         cout<<"★";
  95.         winner=2;
  96.     }
  97.     else if(c==75)
  98.     {
  99.         cout<<"▲";
  100.         winner=3;
  101.     }
  102.     else
  103.     {
  104.         cout<<"●";
  105.         winner=4;
  106.     }
  107.     cout<<" 先馳得點!"<<endl;
  108.     cout<<"------------------------------------------------------------------------| 終點"<<endl;
  109.     for(int i=1; i<=a; i++)
  110.         cout<<" ";
  111.     cout<<"◆"<<endl;
  112.     for(int i=1; i<=b; i++)
  113.         cout<<" ";
  114.     cout<<"★"<<endl;
  115.     for(int i=1; i<=c; i++)
  116.         cout<<" ";
  117.     cout<<"▲"<<endl;
  118.     for(int i=1; i<=d; i++)
  119.         cout<<" ";
  120.     cout<<"●"<<endl<<endl;
  121.     if(option==winner)
  122.     {
  123.         cout<<"贏了"<<bet*3<<"元!"<<endl;
  124.         balance+=bet*3;
  125.         money+=bet*3;                  
  126.     }else
  127.     {
  128.         cout<<"損失"<<bet<<"元!"<<endl;
  129.         balance-=bet;
  130.         money-=bet;
  131.     }
  132.     system("pause");
  133.     n++;
  134.     goto re1;
  135.     end:
  136.     if(money==0)
  137.     {
  138.         cout<<"沒輸沒贏! 全身而退!"<<endl;
  139.     }else if(money>0)
  140.     {
  141.         cout<<"恭喜你! 這次總共贏了"<<money<<"元!"<<endl;  
  142.     }else
  143.     {
  144.         cout<<"不好意思! 讓你損失了"<<money<<"元!"<<endl;  
  145.     }
  146.     cout<<"謝謝光臨! 下次再來!"<<endl;   
  147.     system("pause");
  148.     return 0;   
  149. }
複製代碼
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int s=1,m=0,bg=0;
  7.     re:
  8.       
  9.     int a=0,b=0,c=0,d=0,r,o,z,h,w;
  10.     system("cls");
  11.     cout<<"賽馬場 第"<<s<<"局"<<endl;
  12.     cout<<"--------------------------------------------------------------------|終點"<<endl;
  13.    
  14.     cout<<"◆"<<endl;
  15.     cout<<"★"<<endl;
  16.     cout<<"▲"<<endl;
  17.     cout<<"●"<<endl;
  18.     cout<<"可用餘額: "<<m<<"元"<<endl<<endl;
  19.     cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
  20.     cin>>o;
  21.     if(o==1)
  22.     {
  23.             cout<<"買入: ";
  24.             cin>>z;
  25.             m=m+z;
  26.             goto re;
  27.     }else if(o==2)
  28.     {
  29.         cout<<"請下注: ";
  30.         cin>>z;
  31.         if(z > m)  
  32.         {
  33.             cout<<"餘額不足,請重新下注!"<<endl;
  34.             system("pause");
  35.             goto re;
  36.         }else if(z>=0 && z<= m)
  37.         {
  38.             cout<<"(1)◆馬 (2)★馬 (3)▲馬 (4)●馬 請選擇:";
  39.             cin>>h;
  40.             cout<<"比賽即將開始!"<<endl<<endl;   
  41.          }
  42.     }else if(o==3)
  43.     {
  44.         goto end;  
  45.     }
  46.         else
  47.         {
  48.             cout<<"您輸入錯誤!!請重新下注!"<<endl;
  49.             system("pause");
  50.             goto re;
  51.         }
  52.   
  53.             
  54.     system("pause");
  55.     system("cls");
  56.     srand(time(NULL));
  57.    
  58.     while(a!=70 && b!=70 && c!=70 && d!=70)
  59.       {
  60.      cout<<"起跑嘍~~~~~"<<endl;
  61.      cout<<"------------------------------------------------------------------------| 終點"<<endl;         
  62.      
  63.       r = rand()%4+1;   
  64.             if(r==1)
  65.                 a++;  
  66.             if(r==2)
  67.                 b++;  
  68.             if(r==3)
  69.                 c++;  
  70.             if(r==4)
  71.                 d++;
  72.                
  73.              for(int i=0;i<=a;i++)  
  74.              {
  75.                   cout<<" ";
  76.              }
  77.              cout<<"◆"<<endl;
  78.              for(int i=0;i<=b;i++)
  79.              {  
  80.                   cout<<" ";
  81.              }
  82.              cout<<"★"<<endl;
  83.             
  84.              for(int i=0;i<=c;i++)
  85.              {  
  86.                   cout<<" ";
  87.              }
  88.              cout<<"▲"<<endl;
  89.              for(int i=0;i<=d;i++)  
  90.              {     
  91.                    cout<<" ";
  92.              }
  93.              cout<<"●"<<endl;
  94.              system("cls");
  95.       }
  96.        cout<<"比賽結束! 由";
  97.        if(a==75)
  98.     {
  99.         cout<<"◆";
  100.         w = 1;
  101.     }
  102.     else if(b==75)
  103.     {
  104.         cout<<"★";
  105.         w = 2;
  106.     }
  107.     else if(c==75)
  108.     {
  109.         cout<<"▲";
  110.         w = 3;
  111.     }
  112.     else
  113.     {
  114.         cout<<"●";
  115.         w = 4;
  116.     }
  117.     cout<<"先馳得點"<<endl;
  118.       
  119.      cout<<"------------------------------------------------------------------------| 終點"<<endl;      
  120.      for(int i=0;i<=a;i++)
  121.      {
  122.               cout<<" ";
  123.      }
  124.      cout<<"◆"<<endl;
  125.      for(int i=0;i<=b;i++)
  126.      {
  127.              cout<<" ";
  128.      }
  129.      cout<<"★"<<endl;
  130.      for(int i=0;i<=c;i++)
  131.      {
  132.              cout<<" ";
  133.      }
  134.      cout<<"▲"<<endl;
  135.      for(int i=0;i<=d;i++)
  136.      {
  137.              cout<<" ";
  138.      }
  139.      cout<<"●"<<endl;
  140.      
  141.      if(h==w)
  142.      {
  143.              m=m+(z*3);
  144.              cout<<"贏了"<<z*3<<"元!"<<endl;
  145.              bg+=z*3;
  146.      }else
  147.      {
  148.           m=m-z;
  149.           cout<<"損失"<<z<<"元!"<<endl;
  150.           bg-=z;
  151.      }
  152.      
  153.       system("pause");

  154.         s++;
  155.       goto re;
  156.       end:
  157.          
  158.           if(bg==0)
  159.     {
  160.         cout<<"沒輸沒贏!"<<endl;
  161.     }else if(bg>0)
  162.     {
  163.         cout<<"恭喜你! 這次總共贏了"<<bg<<"元!"<<endl;  
  164.     }else
  165.     {
  166.         cout<<"哈哈 你損失了"<<-bg<<"元!"<<endl;  
  167.     }
  168.     cout<<"銘謝惠顧! 下次再來!"<<endl;   
  169.    
  170.     system("pause");
  171.     return 0;
  172. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n=1,f=0,win,money=0;
  7.     re:
  8.     int a=0,b=0,c=0,d=0,r,j,k,bet,horse,winner;
  9.     system("cls");
  10.     cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
  11.     cout<<"------------------------------------------------------------------------| 終點"<<endl;
  12.     cout<<"◆"<<endl;
  13.     cout<<"★"<<endl;
  14.     cout<<"▲"<<endl;
  15.     cout<<"●"<<endl;
  16.     cout<<endl;
  17.     cout<<"可用餘額: "<<f<<"元"<<endl;
  18.     cout<<"(1)買入(2)下注(3)離開 請選擇: "<<endl;
  19.     cin>>j;
  20.     if(j==1)
  21.     {
  22.         cout<<"買入: ";
  23.         cin>>k;
  24.         f+=k;   
  25.         goto re;
  26.     }else if(j==2)
  27.     {
  28.         cout<<"請下注";
  29.         cin>>bet;
  30.         if(bet>k)
  31.         {
  32.             cout<<"您餘額不足,請重新下注!"<<endl;
  33.             system("pause");
  34.             goto re;
  35.         }else if(bet>=0 && bet<= f)
  36.         {
  37.         
  38.                 cout<<"(1)◆ (2)★ (3)▲(4)● 請選擇:";
  39.                 cin>>horse;
  40.                 cout<<"比賽即將開始"<<endl;
  41.         }else
  42.         {
  43.             cout<<"您輸入錯誤!!請重新下注!"<<endl;
  44.             system("pause");
  45.             goto re;   
  46.         }
  47.         
  48.     }else
  49.     {
  50.         goto end;
  51.     }
  52.      
  53.     system("pause");
  54.     system("cls"); //清空畫面
  55.     srand(time(NULL)); //撒亂樹種子
  56.    
  57.     while(a!=70 && b!=70 && c!=70&& d!=70) //判斷四隻馬只要有一隻到終點就跳離while
  58.     {
  59.           cout<<"賽馬進行中"<<endl;
  60.           cout<<"------------------------------------------------------------------------| 終點"<<endl;         
  61.             r = rand()%4+1;  //產生1~4亂數  隨機挑馬1~4其中一隻
  62.             if(r==1)
  63.                 a++;  
  64.             if(r==2)
  65.                 b++;  
  66.             if(r==3)
  67.                 c++;  
  68.             if(r==4)
  69.                 d++;  
  70.                
  71.                  
  72.              for(int i=0;i<=a;i++)  //第一匹馬前進
  73.              {
  74.                   cout<<" ";
  75.              }
  76.              cout<<"◆"<<endl;
  77.              for(int i=0;i<=b;i++)  //第二匹馬前進
  78.              {
  79.                   cout<<" ";
  80.              }
  81.              cout<<"★"<<endl;
  82.              for(int i=0;i<=c;i++)  //第三匹馬前進
  83.              {
  84.                   cout<<" ";
  85.              }
  86.              cout<<"▲"<<endl;
  87.              for(int i=0;i<=d;i++)  //第四匹馬前進
  88.              {     
  89.                    cout<<" ";
  90.              }
  91.              cout<<"●"<<endl;
  92.              system("cls"); //清空畫面
  93.     }
  94.      
  95.      
  96.      cout<<"賽馬結束!";
  97.      if(a==70)
  98.      {
  99.         cout<<"由◆先馳得點!"<<endl;
  100.      }else if(b==70)
  101.      {
  102.         cout<<"由★先馳得點!"<<endl;
  103.      }else if(c==70)
  104.      {
  105.         cout<<"由▲先馳得點!"<<endl;
  106.      }else
  107.      {
  108.         cout<<"由●先馳得點!"<<endl;
  109.      }
  110.       
  111.       
  112.       
  113.    
  114.      cout<<"------------------------------------------------------------------------| 終點"<<endl;      
  115.      for(int i=0;i<=a;i++)  //第一匹馬最後的位子
  116.      {      
  117.              cout<<" ";
  118.      }
  119.      cout<<"◆"<<endl;
  120.      for(int i=0;i<=b;i++)  //第二匹馬最後的位子
  121.      {        
  122.               cout<<" ";
  123.      }
  124.      cout<<"★"<<endl;
  125.      for(int i=0;i<=c;i++)  //第三匹馬最後的位子
  126.      {
  127.               cout<<" ";
  128.      }
  129.      cout<<"▲"<<endl;
  130.      for(int i=0;i<=d;i++)  //第四匹馬最後的位子
  131.      {     
  132.               cout<<" ";
  133.      }
  134.      cout<<"●"<<endl;
  135.      if(horse==winner)
  136.       {
  137.       cout<<"贏了"<<bet*3<<"元!"<<endl;
  138.        f+=bet*3;
  139.        money=bet*3;                              
  140.        }else
  141.        {
  142.             
  143.        f-=bet;
  144.        money-=bet;
  145.        cout<<"損失"<<bet<<"元"<<endl;     
  146.        }
  147.     n++;  
  148.     system("pause");
  149.     system("cls");
  150.     goto re;
  151.     end:
  152.      if(money==0)
  153.      {
  154.       cout<<"沒輸沒贏!全身而退"<<endl;   
  155.      }else if(money>0)
  156.      {
  157.       cout<<"恭喜你! 贏了"<<money<<"元"<<endl;   
  158.      }else
  159.      {
  160.      cout<<"不好意思,讓你輸了"<<-money<<"元"<<endl;
  161.      }  
  162.     system("pause");
  163.     return 0;   
  164. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n=1,money=0,total=0;
  7.     re:
  8.     int a=0,b=0,c=0,d=0,r,option,buyin,bet,horse,winner;
  9.     system("cls");
  10.     cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
  11.     cout<<"------------------------------------------------------------------------| 終點"<<endl;
  12.     cout<<"◆"<<endl;
  13.     cout<<"★"<<endl;
  14.     cout<<"▲"<<endl;
  15.     cout<<"●"<<endl;
  16.     cout<<"\n可用金額:"<<money<<"元\n"<<endl;
  17.     cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
  18.     cin>>option;
  19.     if(option==1)
  20.     {
  21.         cout<<"請買入:";
  22.         cin>>buyin;
  23.         if(buyin<0)
  24.         {
  25.             cout<<"您輸入的金額有誤,請重新買入!"<<endl;
  26.         }
  27.         money+=buyin;
  28.         goto re;            
  29.     }
  30.     else if(option==2)
  31.     {
  32.         cout<<"請下注:";
  33.         cin>>bet;
  34.         if(bet>money)
  35.         {
  36.             cout<<"您的金額不足,請重新下注!"<<endl;            
  37.             system("pause");
  38.             goto re;
  39.         }
  40.         else if(bet>=0 && bet<=money)
  41.         {
  42.             cout<<"(1)◆ (2)★ (3)▲ (4)● 請選擇:";
  43.             cin>>horse;
  44.             if(horse!=1 && horse!=2 && horse!=3 && horse!=4)
  45.             {
  46.                 cout<<"您輸入的編號有誤,請重新選擇!"<<endl;
  47.                 system("pause");
  48.                 goto re;               
  49.             }
  50.             else
  51.             {
  52.                 cout<<"比賽即將開始!\n\n";
  53.             }     
  54.         }
  55.         else
  56.         {
  57.             cout<<"您輸入的金額有誤,請重新下注!"<<endl;
  58.             system("pause");
  59.             goto re;   
  60.         }         
  61.     }
  62.     else if(option==3)
  63.     {
  64.         goto end;     
  65.     }
  66.     else
  67.     {
  68.         cout<<"您輸入錯誤,請重新選擇!"<<endl;
  69.         system("pause");
  70.         goto re;   
  71.     }
  72.     system("pause");
  73.     system("cls");
  74.     srand(time(NULL));
  75.     while(a!=70 && b!=70 && c!=70 && d!=70)
  76.     {
  77.         cout<<"比賽進行中"<<endl;
  78.         cout<<"------------------------------------------------------------------------| 終點"<<endl;
  79.         r=rand()%4+1;
  80.         if(r==1)
  81.         {
  82.             a++;        
  83.         }
  84.         if(r==2)
  85.         {
  86.             b++;        
  87.         }
  88.         if(r==3)
  89.         {
  90.             c++;        
  91.         }
  92.         if(r==4)
  93.         {
  94.             d++;        
  95.         }
  96.         for(int i=0;i<=a;i++)
  97.         {
  98.             cout<<" ";        
  99.         }
  100.         cout<<"◆"<<endl;
  101.         for(int i=0;i<=b;i++)
  102.         {
  103.             cout<<" ";        
  104.         }
  105.         cout<<"★"<<endl;
  106.         for(int i=0;i<=c;i++)
  107.         {
  108.             cout<<" ";        
  109.         }
  110.         cout<<"▲"<<endl;
  111.         for(int i=0;i<=d;i++)
  112.         {
  113.             cout<<" ";        
  114.         }
  115.         cout<<"●"<<endl;
  116.         system("cls");            
  117.     }
  118.     cout<<"比賽結束!由";
  119.     if(a==70)
  120.     {
  121.         cout<<"◆";
  122.         winner=1;         
  123.     }
  124.     if(b==70)
  125.     {
  126.         cout<<"★";
  127.         winner=2;        
  128.     }
  129.     if(c==70)
  130.     {
  131.         cout<<"▲";
  132.         winner=3;      
  133.     }
  134.     if(d==70)
  135.     {
  136.         cout<<"●";
  137.         winner=4;         
  138.     }
  139.     cout<<"先馳得點!"<<endl;
  140.     cout<<"------------------------------------------------------------------------| 終點"<<endl;
  141.     for(int i=0;i<=a;i++)
  142.     {
  143.         cout<<" ";        
  144.     }
  145.     cout<<"◆"<<endl;
  146.     for(int i=0;i<=b;i++)
  147.     {
  148.         cout<<" ";        
  149.     }
  150.     cout<<"★"<<endl;
  151.     for(int i=0;i<=c;i++)
  152.     {
  153.         cout<<" ";        
  154.     }
  155.     cout<<"▲"<<endl;
  156.     for(int i=0;i<=d;i++)
  157.     {
  158.         cout<<" ";        
  159.     }
  160.     cout<<"●"<<endl;
  161.     if(horse==winner)
  162.     {
  163.         money+=bet*3;
  164.         cout<<"贏了"<<bet*3<<"元!"<<endl;
  165.         total+=bet*3;                 
  166.     }
  167.     else
  168.     {
  169.         money-=bet;
  170.         cout<<"損失"<<bet<<"元!"<<endl;
  171.         total-=bet;
  172.     }
  173.     system("pause");
  174.     system("cls");
  175.     n++;
  176.     goto re;
  177.     end:
  178.     if(total>0)
  179.     {
  180.         cout<<"\n恭喜您,贏了"<<total<<"元!\n"<<endl;
  181.     }
  182.     else if(total<0)
  183.     {
  184.         cout<<"\n不好意思,讓您損失了"<<-total<<"元!\n"<<endl;
  185.     }
  186.     else
  187.     {
  188.         cout<<"\n不輸不贏,全身而退!\n"<<endl;
  189.     }
  190.     cout<<"謝謝光臨,下次再來!"<<endl;
  191.     system("pause");
  192.     return 0;   
  193. }
複製代碼

TOP

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

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n=1,mon=0,in,choose,out=0,peo;
  7.     re:
  8.     int a=0,b=0,c=0,d=0,h;
  9.     cout<<"「好事成雙」賽馬場"<<"第"<<n<<"場"<<endl;
  10.     cout<<"|--------------------------------------------------|"<<endl;
  11.     cout<<"◆"<<endl;
  12.     cout<<"★"<<endl;
  13.     cout<<"▲"<<endl;
  14.     cout<<"●"<<endl;
  15.     cout<<"可用餘額為"<<mon<<endl;
  16.     cout<<"1.買入\t2.下注\t3.離開"<<endl;
  17.     cin>>choose;
  18.    
  19.     if(choose==1)
  20.     {   system("cls");         
  21.      cout<<"請輸入買入金額:";
  22.      cin>>in ;      
  23.      mon+=in;
  24.      system("cls");
  25.      goto re;     
  26.     }
  27.     else if(choose==2)
  28.     {
  29.      cout<<"請輸入下注金額:";
  30.      cin>>out;
  31.      if(mon>=out && out>=1)
  32.      {
  33.       cout<<"下注對象\ta:◆\tb:★\tc:▲\td:●:";
  34.       cin>>peo;           
  35.       mon-=out;
  36.       goto start;
  37.      }else
  38.      {cout<<"錯誤";
  39.       system("pause");
  40.       system("cls");
  41.       goto re;
  42.      }
  43.     }else
  44.      { system("cls");
  45.           goto end;
  46.      }
  47.    
  48.     srand(time(NULL));
  49.    start:
  50.     system("pause");
  51.     system("cls");
  52.     while(a!=50 && b!=50 && c!=50 && d!=50)
  53.     {
  54.           cout<<"賽馬進行中"<<endl;
  55.           cout<<"|--------------------------------------------------|"<<endl;
  56.           h = rand()%4+1;
  57.           if(h==1)
  58.              a++;
  59.           if(h==2)
  60.              b++;
  61.           if(h==3)
  62.              c++;
  63.           if(h==4)
  64.              d++;
  65.             
  66.           for(int i=0;i<=a;i++)
  67.           {
  68.                   cout<<" ";
  69.           }
  70.           cout<<"◆"<<endl;
  71.           for(int i=0;i<=b;i++)
  72.           {
  73.                   cout<<" ";
  74.           }
  75.           cout<<"★"<<endl;
  76.           for(int i=0;i<=c;i++)
  77.           {
  78.                   cout<<" ";
  79.           }
  80.           cout<<"▲"<<endl;
  81.           for(int i=0;i<=d;i++)
  82.           {
  83.                   cout<<" ";
  84.           }
  85.           cout<<"●"<<endl;
  86.           system("cls");
  87.     }
  88.     cout<<"比賽結束\t";
  89.     if(a==50)
  90.     {cout<<"由◆拿下勝利";
  91.     if(peo==a)
  92.     {
  93.      cout<<"贏得"<<out*3<<endl;         
  94.      mon+=out*3;
  95.     }else
  96.     {cout<<"損失"<<out<<endl;
  97.     }
  98.     }
  99.     else if(b==50)
  100.     {cout<<"由★拿下勝利";
  101.      if(peo==a)
  102.     {
  103.      cout<<"贏得"<<out*3<<endl;         
  104.      mon+=out*3;
  105.     }else
  106.     {cout<<"損失"<<out<<endl;
  107.     }
  108.    
  109.     }
  110.     else if(c==50)
  111.     {cout<<"由▲拿下勝利";
  112.      if(peo==a)
  113.     {
  114.      cout<<"贏得"<<out*3<<endl;         
  115.      mon+=out*3;
  116.     }else
  117.     {cout<<"損失"<<out<<endl;
  118.     }
  119.    
  120.     }
  121.     else
  122.     {cout<<"由●拿下勝利";
  123.     if(peo==a)
  124.     {
  125.      cout<<"贏得"<<out*3<<endl;         
  126.      mon+=out*3;
  127.     }else
  128.     {cout<<"損失"<<out<<endl;
  129.     }
  130.    
  131.     }
  132.    
  133.     cout<<"|--------------------------------------------------|"<<endl;
  134.     for(int i=0;i<=a;i++)
  135.     {
  136.         cout<<" ";
  137.     }
  138.     cout<<"◆"<<endl;
  139.     for(int i=0;i<=b;i++)
  140.     {
  141.         cout<<" ";
  142.     }
  143.     cout<<"★"<<endl;
  144.     for(int i=0;i<=c;i++)
  145.     {
  146.         cout<<" ";
  147.     }
  148.     cout<<"▲"<<endl;
  149.     for(int i=0;i<=d;i++)
  150.     {     
  151.         cout<<" ";
  152.     }
  153.     cout<<"●"<<endl;
  154.    
  155.     system("pause");
  156.     system("cls");
  157.     n++;
  158.     goto re;
  159.     end:
  160.     system("pause");
  161.     system("cls");
  162.     return 0;
  163. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int t=1,m=0,total=0;
  7.     re:
  8.     system("cls");
  9.     int a=0,b=0,c=0,d=0,r,choose,in,bet,h,w;
  10.     cout<<"「好事成雙」賽馬場 第"<<t<<"局"<<endl;
  11.     cout<<"------------------------------------------------------------------------| 終點"<<endl;
  12.     cout<<"◆"<<endl;
  13.     cout<<"★"<<endl;
  14.     cout<<"▲"<<endl;
  15.     cout<<"●"<<endl<<endl;
  16.     cout<<"可用餘額:"<<m<<"元"<<endl<<endl;
  17.     cout<<"(1)買入  (2)下注  (3)離開  請選擇:";
  18.     cin>>choose;
  19.     if(choose==1)
  20.     {
  21.           w1:
  22.           cout<<"買入: ";
  23.           cin>>in;
  24.           if(in>0)
  25.           {     
  26.                 m=m+in;
  27.                 goto re;      
  28.           }
  29.           else
  30.           {
  31.                 cout<<"輸入錯誤"<<endl;
  32.                 system("pause");
  33.                 goto w1;     
  34.           }
  35.     }else if(choose==2)
  36.     {
  37.           cout<<"請下注:";
  38.           cin>>bet;
  39.           cout<<endl;
  40.           if(bet>m)
  41.           {
  42.                 cout<<"您餘額不足,請重新輸入!"<<endl;
  43.                 system("pause");
  44.                 goto re;
  45.           }else if(bet>=0 && bet<= m)
  46.           {
  47.                 cout<<"(1)◆ (2)★ (3)▲(4)● 請選擇:";
  48.                 cin>>h;
  49.                 cout<<"比賽即將開始!"<<endl<<endl;
  50.           }else
  51.           {
  52.                 cout<<"輸入錯誤"<<endl;
  53.                 system("pause");
  54.                 goto re;
  55.           }
  56.     }else if(choose==3)
  57.     {
  58.           goto end;
  59.     }else
  60.     {
  61.           cout<<"輸入錯誤"<<endl;
  62.           system("pause");
  63.           goto re;            
  64.     }   
  65.     system("pause");
  66.     system("cls");
  67.     srand(time(NULL));
  68.     while(a!=70 && b!=70 && c!=70 && d!=70)
  69.     {
  70.           cout<<"比賽進行中"<<endl;
  71.           cout<<"------------------------------------------------------------------------| 終點"<<endl;
  72.           r=rand()%4+1;
  73.           if(r==1)
  74.           {
  75.                 a++;
  76.           }
  77.           if(r==2)
  78.           {
  79.                 b++;
  80.           }         
  81.           if(r==3)
  82.           {
  83.                 c++;
  84.           }         
  85.           if(r==4)
  86.           {
  87.                 d++;
  88.           }
  89.           for(int i=0;i<=a;i++)
  90.           {
  91.                 cout<<" ";
  92.           }
  93.           cout<<"◆"<<endl;
  94.           for(int i=0;i<=b;i++)
  95.           {
  96.                 cout<<" ";
  97.           }
  98.           cout<<"★"<<endl;
  99.           for(int i=0;i<=c;i++)
  100.           {
  101.                 cout<<" ";
  102.           }
  103.           cout<<"▲"<<endl;
  104.           for(int i=0;i<=d;i++)
  105.           {
  106.                 cout<<" ";
  107.           }
  108.           cout<<"●"<<endl;
  109.           system("cls");                  
  110.     }
  111.     cout<<"比賽結束!由";
  112.     if(a==70)
  113.     {
  114.           cout<<"◆";
  115.           w=1;      
  116.     }
  117.     else if(b==70)
  118.     {
  119.           cout<<"★";
  120.           w=2;      
  121.     }
  122.     else if(c==70)
  123.     {
  124.           cout<<"▲";
  125.           w=3;      
  126.     }
  127.     else if(d==70)
  128.     {
  129.           cout<<"●";
  130.           w=4;      
  131.     }
  132.     cout<<"先馳得點!"<<endl;
  133.     cout<<"------------------------------------------------------------------------| 終點"<<endl;
  134.     for(int i=0;i<=a;i++)
  135.     {
  136.           cout<<" ";
  137.     }
  138.     cout<<"◆"<<endl;
  139.     for(int i=0;i<=b;i++)
  140.     {
  141.           cout<<" ";
  142.     }
  143.     cout<<"★"<<endl;
  144.     for(int i=0;i<=c;i++)
  145.     {
  146.           cout<<" ";
  147.     }
  148.     cout<<"▲"<<endl;
  149.     for(int i=0;i<=d;i++)
  150.     {
  151.           cout<<" ";
  152.     }
  153.     cout<<"●"<<endl;
  154.     if(h==w)
  155.     {
  156.           m=m+bet*3;
  157.           cout<<"贏了"<<bet*3<<"元"<<endl;
  158.           total=total+bet*3;   
  159.     }else
  160.     {
  161.           m=m-bet;
  162.           cout<<"損失"<<bet<<"元"<<endl;
  163.           total=total-bet;  
  164.     }
  165.     system("pause");
  166.     system("cls");
  167.     t++;
  168.     goto re;
  169.     end:
  170.     cout<<endl;
  171.     if(total>0)
  172.     {
  173.           cout<<"恭喜你!這次總共贏了"<<total<<"元!"<<endl;
  174.     }else if(total<0)
  175.     {
  176.           cout<<"不好意思!讓你損失了"<<-total<<"元!"<<endl;
  177.     }else
  178.     {
  179.           cout<<"沒輸沒贏!全身而退!"<<endl;
  180.     }
  181.     cout<<endl;
  182.     cout<<"謝謝光臨!下次再來!"<<endl;
  183.     system("pause");
  184.     return 0;
  185. }
複製代碼

TOP

返回列表