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

TOP

返回列表