返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include <time.h>
  4. using namespace std;
  5. int main()
  6. {
  7.     int g=1,rest=0,bet=0;
  8.     re:
  9.     int a=0,b=0,c=0,d=0,p,option,buyin=0,horse;
  10.     system("cls");
  11.     cout<<"「好事成雙」賽馬場 第"<<g<<"局"<<endl;
  12.     cout<<"|--------------------------------------------------|"<<endl;
  13.     cout<<"◆"<<endl;
  14.     cout<<"★"<<endl;
  15.     cout<<"▲"<<endl;
  16.     cout<<"●"<<endl;
  17.     cout<<"可用餘額"<<rest<<"元"<<endl<<endl;
  18.     cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
  19.     cin>>option;
  20.     if(option==1)
  21.     {
  22.           cout<<"買入金額:";
  23.           cin>>buyin;
  24.           rest+=buyin;
  25.           goto re;
  26.     }else if(option==2)
  27.     {
  28.           cout<<"下注金額: ";
  29.           cin>>bet;
  30.           if(rest<bet)
  31.           {
  32.                 cout<<"餘額不足,請重新下注"<<endl;
  33.                 system("pause");
  34.                 goto re;
  35.           }else if(bet>=0 && rest>=bet)
  36.           {
  37.                 rest-=bet;
  38.                 cout<<"(1)◆ (2)★ (3)▲ (4)●請選擇:" ;
  39.                 cin>>horse;
  40.                 cout<<"比賽即將開始!"<<endl<<endl;
  41.           }else
  42.           {
  43.                cout<<"您輸入錯誤,請重新下注"<<endl;
  44.                system("pause");
  45.                goto re;
  46.           }
  47.     }else if(option==3)
  48.     {
  49.           goto end;
  50.     }else
  51.     {
  52.           cout<<"輸入錯誤"<<endl;
  53.           system("pause");
  54.           goto re;
  55.     }
  56.     system("pause");
  57.     srand(time(NULL));
  58.     while(a!=50 && b!=50 && c!=50 && d!=50)
  59.     {
  60.           cout<<"賽馬進行中"<<endl;
  61.           cout<<"|--------------------------------------------------|"<<endl;
  62.           p = rand()%4+1;
  63.           if(p==1)
  64.              a++;
  65.           if(p==2)
  66.              b++;
  67.           if(p==3)
  68.              c++;
  69.           if(p==4)
  70.              d++;
  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.     if(a==50)
  95.     {
  96.     cout<<"比賽結束 由◆先馳得點"<<endl;
  97.     }
  98.     if(b==50)
  99.     {
  100.     cout<<"比賽結束 由★先馳得點"<<endl;
  101.     }
  102.     if(c==50)
  103.     {
  104.     cout<<"比賽結束 由▲先馳得點"<<endl;
  105.     }
  106.     if(d==50)
  107.     {
  108.     cout<<"比賽結束 由●先馳得點"<<endl;
  109.     }
  110.     cout<<"|--------------------------------------------------|"<<endl;
  111.     for(int i=0;i<=a;i++)
  112.     {
  113.         cout<<" ";
  114.     }
  115.     cout<<"◆"<<endl;
  116.     for(int i=0;i<=b;i++)
  117.     {
  118.         cout<<" ";
  119.     }
  120.     cout<<"★"<<endl;
  121.     for(int i=0;i<=c;i++)
  122.     {
  123.         cout<<" ";
  124.     }
  125.     cout<<"▲"<<endl;
  126.     for(int i=0;i<=d;i++)
  127.     {     
  128.         cout<<" ";
  129.     }
  130.     cout<<"●"<<endl;
  131.     system("pause");
  132.     system("cls");
  133.     g++;
  134.     goto re;
  135.     end:
  136.     cout<<"結束"<<endl;
  137.     system("pause");
  138.     return 0;
  139. }
複製代碼
回復 1# 陳品肇

TOP

返回列表