返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n=1,money=0;
  7.     re:
  8.     int a=0, b=0, c=0, d=0, r, option, buyin, bet, horse;
  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<<"可用餘額: "<<money<<"元"<<endl<<endl;
  18.     cout<<"(1)買入  (2)下注  (3)離開  請選擇: ";
  19.     cin>>option;
  20.     if(option==1)
  21.     {
  22.         cout<<"買入: ";
  23.         cin>>buyin;
  24.         money+=buyin;  
  25.         goto re;
  26.     }else if(option ==2)
  27.     {
  28.         cout<<"請下注: ";
  29.         cin>>bet;
  30.         if(bet > money)  
  31.         {
  32.             cout<<"您餘額不足,請重新下注!"<<endl;
  33.             system("pause");
  34.             goto re;
  35.         }else if(bet>=0 && bet<= money)
  36.         {
  37.             money -= bet;
  38.             cout<<"(1)◆ (2)★ (3)▲(4)● 請選擇:";
  39.             cin>>horse;
  40.             cout<<"比賽即將開始!"<<endl<<endl;
  41.       
  42.         }else
  43.         {
  44.             cout<<"您輸入錯誤!!請重新下注!"<<endl;
  45.             system("pause");
  46.             goto re;
  47.         }
  48.     }else  
  49.     {
  50.         goto end;
  51.     }
  52.     system("pause");
  53.     system("cls");
  54.     srand(time(NULL));
  55.     while(a!=75 && b!=75 && c!=75 && d!=75)
  56.     {
  57.         r=rand()%4;   
  58.         if(r==0)
  59.             a++;
  60.         else if(r==1)
  61.             b++;
  62.         else if(r==2)
  63.             c++;
  64.         else
  65.             d++;
  66.         cout<<"比賽進行中"<<endl;
  67.         cout<<"------------------------------------------------------------------------| 終點"<<endl;
  68.         for(int i=1; i<=a; i++)
  69.             cout<<" ";
  70.         cout<<"◆"<<endl;
  71.         for(int i=1; i<=b; i++)
  72.             cout<<" ";
  73.         cout<<"★"<<endl;
  74.         for(int i=1; i<=c; i++)
  75.             cout<<" ";
  76.         cout<<"▲"<<endl;
  77.         for(int i=1; i<=d; i++)
  78.             cout<<" ";
  79.         cout<<"●"<<endl;   
  80.         system("cls");      
  81.     }
  82.     cout<<"比賽結束! 由 ";
  83.     if(a==75)
  84.         cout<<"◆";
  85.     else if(b==75)
  86.         cout<<"★";
  87.     else if(c==75)
  88.         cout<<"▲";
  89.     else
  90.         cout<<"●";
  91.     cout<<" 先馳得點!"<<endl;
  92.     cout<<"------------------------------------------------------------------------| 終點"<<endl;
  93.     for(int i=1; i<=a; i++)
  94.         cout<<" ";
  95.     cout<<"◆"<<endl;
  96.     for(int i=1; i<=b; i++)
  97.         cout<<" ";
  98.     cout<<"★"<<endl;
  99.     for(int i=1; i<=c; i++)
  100.         cout<<" ";
  101.     cout<<"▲"<<endl;
  102.     for(int i=1; i<=d; i++)
  103.         cout<<" ";
  104.     cout<<"●"<<endl;
  105.     system("pause");
  106.     n++;
  107.     goto re;
  108.     end:
  109.     system("pause");
  110.     return 0;   
  111. }
複製代碼

TOP

返回列表