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

TOP

返回列表