返回列表 發帖
  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.     cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
  12.     cout<<"------------------------------------------------------------------------| 終點"<<endl;
  13.     cout<<"◆"<<endl;
  14.     cout<<"★"<<endl;
  15.     cout<<"▲"<<endl;
  16.     cout<<"●"<<endl;
  17.     cout<<endl;
  18.     cout<<"可用餘額:"<<blance<<"元"<<endl;
  19.     cout<<endl;
  20.     cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
  21.     cin>>option;
  22.    
  23.     if(option==1)
  24.     {
  25.         cout<<"買入:";
  26.         cin>>buyin;
  27.         blance += buyin;
  28.         goto re;
  29.     }else if(option==2)
  30.     {
  31.         cout<<"請下注:";
  32.         cin>>bet;
  33.         if(bet > blance)
  34.         {
  35.            cout<<"您餘額不足,請重新下注!"<<endl;
  36.         }else if(bet >0 && bet<=blance)
  37.         {
  38.            cout<<"(1)◆ (2)★ (3)▲(4)●請選擇:";
  39.            cin>>horse;
  40.            blance -= bet;
  41.         }else
  42.         {
  43.            cout<<"您輸入錯誤,請重新下注!"<<endl;
  44.         }
  45.         
  46.         system("pause");
  47.         goto re;
  48.     }else
  49.     {
  50.       
  51.     }
  52.    
  53.     system("pause");
  54.     system("cls");
  55.     srand(time(NULL));

  56.     string words ="賽馬進行中";

  57.     string name[4] = {"◆","★","▲","●"};
  58.    
  59.     int position =0;
  60.     while(a<=70 && b<=70 && c<=70 && d<=70)
  61.     {  
  62.       cout<<words<<endl;
  63.       cout<<"------------------------------------------------------------------------| 終點"<<endl;   

  64.       r = rand()%4+1;

  65.       switch(r)
  66.       {
  67.           case 1:
  68.                a++;
  69.                break;
  70.           case 2:
  71.                b++;
  72.                break;
  73.           case 3:
  74.                c++;
  75.                break;
  76.           case 4:
  77.                d++;
  78.                break;
  79.       }
  80.       
  81.       for(int i=0;i<=a;i++)
  82.       {
  83.           cout<<" ";
  84.       }
  85.       cout<<name[0]<<endl;
  86.       
  87.       for(int i=0;i<=b;i++)
  88.       {
  89.           cout<<" ";
  90.       }
  91.       cout<<name[1]<<endl;
  92.       
  93.       for(int i=0;i<=c;i++)
  94.       {
  95.           cout<<" ";
  96.       }
  97.       cout<<name[2]<<endl;
  98.   
  99.       for(int i=0;i<=d;i++)
  100.       {
  101.           cout<<" ";
  102.       }
  103.       cout<<name[3]<<endl;
  104.       
  105.    
  106.       if(a==70 || b==70 || c==70 || d==70)
  107.       {  
  108.          if(a==70)
  109.               position = 0;
  110.          if(b==70)
  111.               position =1;
  112.          if(c==70)
  113.               position =2;
  114.          if(d==70)
  115.               position =3;           
  116.          
  117.          words = "比賽結束!由"+name[position]+"先馳得點!";
  118.       }

  119.       if(a==71 || b==71 || c==71 || d==71)
  120.       {               
  121.       }else{      
  122.         system("cls");
  123.       }
  124.       
  125.     }

  126.     n++;
  127.     system("pause");
  128.     goto re;     
  129.     system("pause");  
  130.     return 0;   
  131. }
複製代碼

TOP

返回列表