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

TOP

返回列表