返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n=1,mon=0,in,choose,out=0,peo;
  7.     re:
  8.     int a=0,b=0,c=0,d=0,h;
  9.     cout<<"「好事成雙」賽馬場"<<"第"<<n<<"場"<<endl;
  10.     cout<<"|--------------------------------------------------|"<<endl;
  11.     cout<<"◆"<<endl;
  12.     cout<<"★"<<endl;
  13.     cout<<"▲"<<endl;
  14.     cout<<"●"<<endl;
  15.     cout<<"可用餘額為"<<mon<<endl;
  16.     cout<<"1.買入\t2.下注\t3.離開"<<endl;
  17.     cin>>choose;
  18.    
  19.     if(choose==1)
  20.     {   system("cls");         
  21.      cout<<"請輸入買入金額:";
  22.      cin>>in ;      
  23.      mon+=in;
  24.      system("cls");
  25.      goto re;     
  26.     }
  27.     else if(choose==2)
  28.     {
  29.      cout<<"請輸入下注金額:";
  30.      cin>>out;
  31.      if(mon>=out && out>=1)
  32.      {
  33.       cout<<"下注對象\ta:◆\tb:★\tc:▲\td:●:";
  34.       cin>>peo;           
  35.       mon-=out;
  36.       goto start;
  37.      }else
  38.      {cout<<"錯誤";
  39.       system("pause");
  40.       system("cls");
  41.       goto re;
  42.      }
  43.     }else
  44.      { system("cls");
  45.           goto end;
  46.      }
  47.    
  48.     srand(time(NULL));
  49.    start:
  50.     system("pause");
  51.     system("cls");
  52.     while(a!=50 && b!=50 && c!=50 && d!=50)
  53.     {
  54.           cout<<"賽馬進行中"<<endl;
  55.           cout<<"|--------------------------------------------------|"<<endl;
  56.           h = rand()%4+1;
  57.           if(h==1)
  58.              a++;
  59.           if(h==2)
  60.              b++;
  61.           if(h==3)
  62.              c++;
  63.           if(h==4)
  64.              d++;
  65.             
  66.           for(int i=0;i<=a;i++)
  67.           {
  68.                   cout<<" ";
  69.           }
  70.           cout<<"◆"<<endl;
  71.           for(int i=0;i<=b;i++)
  72.           {
  73.                   cout<<" ";
  74.           }
  75.           cout<<"★"<<endl;
  76.           for(int i=0;i<=c;i++)
  77.           {
  78.                   cout<<" ";
  79.           }
  80.           cout<<"▲"<<endl;
  81.           for(int i=0;i<=d;i++)
  82.           {
  83.                   cout<<" ";
  84.           }
  85.           cout<<"●"<<endl;
  86.           system("cls");
  87.     }
  88.     cout<<"比賽結束\t";
  89.     if(a==50)
  90.     {cout<<"由◆拿下勝利";
  91.     if(peo==a)
  92.     {
  93.      cout<<"贏得"<<out*3<<endl;         
  94.      mon+=out*3;
  95.     }else
  96.     {cout<<"損失"<<out<<endl;
  97.     }
  98.     }
  99.     else if(b==50)
  100.     {cout<<"由★拿下勝利";
  101.      if(peo==a)
  102.     {
  103.      cout<<"贏得"<<out*3<<endl;         
  104.      mon+=out*3;
  105.     }else
  106.     {cout<<"損失"<<out<<endl;
  107.     }
  108.    
  109.     }
  110.     else if(c==50)
  111.     {cout<<"由▲拿下勝利";
  112.      if(peo==a)
  113.     {
  114.      cout<<"贏得"<<out*3<<endl;         
  115.      mon+=out*3;
  116.     }else
  117.     {cout<<"損失"<<out<<endl;
  118.     }
  119.    
  120.     }
  121.     else
  122.     {cout<<"由●拿下勝利";
  123.     if(peo==a)
  124.     {
  125.      cout<<"贏得"<<out*3<<endl;         
  126.      mon+=out*3;
  127.     }else
  128.     {cout<<"損失"<<out<<endl;
  129.     }
  130.    
  131.     }
  132.    
  133.     cout<<"|--------------------------------------------------|"<<endl;
  134.     for(int i=0;i<=a;i++)
  135.     {
  136.         cout<<" ";
  137.     }
  138.     cout<<"◆"<<endl;
  139.     for(int i=0;i<=b;i++)
  140.     {
  141.         cout<<" ";
  142.     }
  143.     cout<<"★"<<endl;
  144.     for(int i=0;i<=c;i++)
  145.     {
  146.         cout<<" ";
  147.     }
  148.     cout<<"▲"<<endl;
  149.     for(int i=0;i<=d;i++)
  150.     {     
  151.         cout<<" ";
  152.     }
  153.     cout<<"●"<<endl;
  154.    
  155.     system("pause");
  156.     system("cls");
  157.     n++;
  158.     goto re;
  159.     end:
  160.     system("pause");
  161.     system("cls");
  162.     return 0;
  163. }
複製代碼

TOP

返回列表