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

TOP

返回列表