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

TOP

返回列表