返回列表 發帖
本帖最後由 李沛昂 於 2018-6-11 16:53 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     int dog=1;
  8.     int pig1,pig2=0,pig3=0,pig4,pig5,pig6,pig7;
  9.     re:
  10.     int a,b,c;
  11.     system("cls");
  12.     int pig[]={0,0,0,0};
  13.     srand(time(NULL));
  14.     cout<<"「好事成雙」賭馬場  第"<<dog<<"局"<<endl;
  15.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  16.     cout<<"◆"<<endl;
  17.     cout<<"★"<<endl;
  18.     cout<<"▲"<<endl;
  19.     cout<<"●"<<endl;
  20.     cout<<endl<<"可用餘額: "<<pig3<<endl<<endl;
  21.     re3:
  22.     cout<<"(1)買入 (2)下注 (3)離開  請選擇: ";
  23.     cin>>pig2;
  24.     if(pig2==1)
  25.     {
  26.             re1:
  27.         cout<<"買入: ";
  28.         cin>>pig4;
  29.         if(pig4<=0)
  30.         {
  31.              cout<<"你是白癡嗎?看清楚!!!"<<endl;
  32.              _sleep(1500);
  33.              goto re1;
  34.         }
  35.         pig3+=pig4;
  36.         goto re;      
  37.     }
  38.     if(pig2==2)
  39.     {
  40.         cout<<"下注: ";           
  41.         cin>>pig5;              
  42.         if(pig5<=0)
  43.         {
  44.             cout<<"你是白癡嗎?看清楚!!!"<<endl;
  45.             _sleep(1500);
  46.             goto re1;
  47.         }
  48.         if(pig5>pig3)
  49.         {
  50.             cout<<"餘額不夠,請買入!"<<endl;
  51.             _sleep(1500);
  52.             goto re1;
  53.         }
  54.         cout<<"請選擇  (1)◆(2)★(3)▲(4)●: ";
  55.         cin>>pig6;
  56.         cout<<"比賽即將開始......"<<endl;
  57.         _sleep(1500);
  58.         goto re2;
  59.     }
  60.     if(pig2==3)
  61.     {
  62.         goto end;           
  63.     }
  64.     else
  65.     {
  66.             cout<<"你是白癡嗎?看清楚!!!"<<endl;
  67.             _sleep(1500);
  68.             goto re3;
  69.     }
  70.     system("pause");
  71.     re2:
  72.     while(true)
  73.     {
  74.         system("cls");
  75.         pig1=rand()%4;
  76.         pig[pig1]++;
  77.         cout<<"比賽進行中"<<endl;
  78.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  79.         for(int i=0;i<=pig[0];i++)
  80.             cout<<" ";
  81.         cout<<"◆"<<endl;         
  82.         for(int i=0;i<=pig[1];i++)
  83.             cout<<" ";
  84.         cout<<"★"<<endl;         
  85.         for(int i=0;i<=pig[2];i++)
  86.             cout<<" ";
  87.         cout<<"▲"<<endl;         
  88.         for(int i=0;i<=pig[3];i++)
  89.             cout<<" ";
  90.         cout<<"●"<<endl;
  91.         if(pig[pig1]==73)
  92.             break;
  93.         _sleep(25);           
  94.     }
  95.     system("cls");
  96.         if(pig1==0)
  97.             cout<<"比賽結束!"<<" 由◆先馳得點!"<<endl;
  98.         else if(pig1==1)
  99.             cout<<"比賽結束!"<<" 由★先馳得點!"<<endl;
  100.         else if(pig1==2)
  101.             cout<<"比賽結束!"<<" 由▲先馳得點!"<<endl;
  102.         else
  103.             cout<<"比賽結束!"<<" 由●先馳得點!"<<endl;
  104.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  105.     for(int i=0;i<=pig[0];i++)
  106.             cout<<" ";
  107.         cout<<"◆"<<endl;         
  108.     for(int i=0;i<=pig[1];i++)
  109.             cout<<" ";
  110.         cout<<"★"<<endl;         
  111.     for(int i=0;i<=pig[2];i++)
  112.             cout<<" ";
  113.         cout<<"▲"<<endl;         
  114.     for(int i=0;i<=pig[3];i++)
  115.             cout<<" ";
  116.         cout<<"●"<<endl;
  117.     if(pig6==1 && pig1==0)
  118.     {
  119.             cout<<"獲得"<<pig5*3<<"元!"<<endl;
  120.                         pig7+=pig5*3;
  121.             pig3+=pig5*3;
  122.         }else if(pig6==2 && pig1==1)
  123.     {
  124.             cout<<"獲得"<<pig5*3<<"元!"<<endl;  
  125.             pig7+=pig5*3;
  126.                         pig3+=pig5*3;
  127.         }else if(pig6==3 && pig1==2)
  128.     {
  129.             cout<<"獲得"<<pig5*3<<"元!"<<endl;
  130.             pig7+=pig5*3;
  131.                         pig3+=pig5*3;
  132.         }else if(pig6==4 && pig1==3)
  133.     {
  134.             cout<<"獲得"<<pig5*3<<"元!"<<endl;
  135.             pig7+=pig5*3;
  136.             pig3+=pig5*3;
  137.         }else
  138.         {
  139.             cout<<"損失"<<pig5<<"元!"<<endl;
  140.             pig7-=pig5;
  141.                         pig3-=pig5;
  142.         }
  143.     system("pause");
  144.     dog++;
  145.     goto re;
  146.     end:
  147.     if(pig7>0)
  148.         {
  149.             cout<<"恭喜你! 這次總共贏了"<<pig7<<"元!"<<endl;
  150.         }
  151.         else if(pig7==0)
  152.         {
  153.             cout<<"沒輸沒贏! 全身而退!"<<endl;
  154.         }
  155.         else
  156.         {
  157.             cout<<"對不起! 讓你損失了"<<-pig7<<"元!"<<endl;
  158.         }
  159.         cout<<endl<<"謝謝光臨! 下次再來!"<<endl;
  160.     system("pause");   
  161.     return 0;
  162. }
複製代碼

TOP

返回列表