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

TOP

返回列表