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

TOP

返回列表