返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.    
  7.     int n=1,balance=0;
  8.     re1:
  9.     int a=0, b=0, c=0, d=0, r,option,;
  10.     system("cls");
  11.     cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<endl;
  12.     cout<<"------------------------------------------------------------------------| 終點"<<endl;
  13.     cout<<"◆"<<endl;
  14.     cout<<"★"<<endl;
  15.     cout<<"▲"<<endl;
  16.     cout<<"●"<<endl;
  17.    
  18.     cout<<endl;
  19.     cout<<"剩餘金額"<<balance<<"元"<<endl<<endl;
  20.     cout<<"(1)買入 (2)下注 (3)離開  選擇:"<<endl;
  21.     cin>>option;
  22.      if(option==1)         
  23.     {
  24.     int tmp;
  25.     cout<<"買入";
  26.     cin>>tmp;
  27.     balance=balance+tmp;
  28.     goto re1;
  29.     }else if(option==2)
  30.     {
  31.       
  32.            if (balance==0)
  33.            {
  34.              cout<<"餘額不足,請先買入"<<endl;
  35.              system("pause");
  36.              goto re1;
  37.            }
  38.            int tmp;
  39.            cout<<"下注";
  40.            cin>>tmp;
  41.            if (tmp>balance)  
  42.            
  43.            if (tmp<balance)            
  44.            {
  45.            cout<<"(1)◆ (2)★ (3)▲(4)●請選擇 "<endl;
  46.            }   
  47.     }else if(option==3)
  48.     {
  49.        goto end;
  50.     }else
  51.     {
  52.       cout<<"輸入錯誤!!"<<endl;
  53.       system("pause");
  54.       goto re1;
  55.     }

  56.     system("pause");
  57.     system("cls");
  58.     srand(time(NULL));
  59.     while(a!=60 && b!=60 && c!=60 && d!=60)
  60.     {
  61.     r=rand()%4;   
  62.       if(r==0)
  63.          a++;
  64.       else if(r==1)
  65.           b++;
  66.       else if(r==2)
  67.           c++;
  68.       else
  69.           d++;
  70.         cout<<"比賽進行中"<<endl;
  71.         cout<<"------------------------------------------------------------| 終點"<<endl;
  72.         
  73.       for(int i=1; i<=a; i++)
  74.          cout<<" ";
  75.          cout<<"◆"<<endl;
  76.          
  77.       for(int i=1; i<=b; i++)
  78.           cout<<" ";
  79.           cout<<"★"<<endl;
  80.         
  81.       for(int i=1; i<=c; i++)
  82.           cout<<" ";
  83.           cout<<"▲"<<endl;
  84.         
  85.       for(int i=1; i<=d; i++)
  86.          cout<<" ";
  87.          cout<<"●"<<endl;   
  88.         system("cls");      
  89.     }

  90.     cout<<"比賽結束";
  91.    
  92.     if(a==60)
  93.        cout<<"◆";
  94.     else if(b==60)
  95.        cout<<"★";
  96.     else if(c==60)
  97.         cout<<"▲";
  98.     else
  99.         cout<<"●";
  100.     cout<<" 先到了!"<<endl;
  101.   
  102.     cout<<"--------------------------------------------------------------| 終點"<<endl;
  103.     for(int i=1; i<=a; i++)
  104.         cout<<" ";
  105.     cout<<"◆"<<endl;
  106.    
  107.     for(int i=1; i<=b; i++)
  108.         cout<<" ";
  109.     cout<<"★"<<endl;
  110.    
  111.     for(int i=1; i<=c; i++)
  112.         cout<<" ";
  113.     cout<<"▲"<<endl;
  114.    
  115.     for(int i=1; i<=d; i++)
  116.         cout<<" ";
  117.     cout<<"●"<<endl;
  118.     system("pause");

  119.     n++;
  120.     goto re1;
  121.     end:
  122.     system("pause");
  123.     return 0;   
  124. }
複製代碼

TOP

返回列表