返回列表 發帖
  1. #include<iostream>
  2. #include<ctime>
  3. using namespace std;
  4. int main()
  5. {
  6.     int e=0;
  7.     int b,d,g,h,money=0;
  8.     srand(time(NULL));
  9. re:
  10.     e++;
  11. start:
  12.     system("cls");
  13.     int a[4]= {0,0,0,0};
  14.     string j[4]= {"△","▲","☆","★"};
  15.     cout<<"賽馬場"<<"第"<<e<<"局"<<endl;
  16.     cout<<"---------------------------------------------------------|終點"<<endl;//57
  17.     cout<<"△"<<endl;
  18.     cout<<"▲"<<endl;
  19.     cout<<"☆"<<endl;
  20.     cout<<"★"<<endl;
  21.     cout<<endl<<endl<<"你的餘額:"<<money<<endl;
  22.     cout<<"[1]買入[2]下注[3]離開:";
  23.     cin>>d;
  24.     if(d==1)
  25.     {
  26.         cout<<"你要買入多少錢?:";
  27.         cin>>b;
  28.         if(b<0)
  29.         {
  30.             cout<<"輸入錯誤";
  31.             _sleep(1500);
  32.             goto start;
  33.         }
  34.         money+=b;
  35.         goto start;
  36.     }
  37.     else if(d==2)
  38.     {
  39.         cout<<"下注:";
  40.         cin>>g;
  41.         if(g>money)
  42.         {
  43.             cout<<"輸入錯誤";
  44.             _sleep(1500);
  45.             goto start;
  46.         }
  47.         if(g<=0)
  48.         {
  49.             cout<<"輸入錯誤";
  50.             _sleep(1500);
  51.             goto start;
  52.         }
  53.         cout<<"請選擇1△ 2▲ 3☆ 4★: ";
  54.         cin>>h;
  55.     }
  56.     else if(d==3)
  57.         goto end;
  58.     else
  59.     {
  60.         cout<<"輸入錯誤";
  61.         _sleep(1500);
  62.         goto start;
  63.     }
  64.     system("pause");
  65.     system("cls");
  66.     while(true)
  67.     {
  68.         system("cls");
  69.         int c=rand()%4;

  70.         cout<<"賽馬場"<<"第"<<e<<"局"<<endl;
  71.         cout<<"---------------------------------------------------------|終點"<<endl;
  72.         a[c]+=3;
  73.         for(int m=1; m<=a[0]; m++)
  74.             cout<<" ";
  75.         cout<<"△"<<endl;
  76.         for(int m=1; m<=a[1]; m++)
  77.             cout<<" ";
  78.         cout<<"▲"<<endl;
  79.         for(int m=1; m<=a[2]; m++)
  80.             cout<<" ";
  81.         cout<<"☆"<<endl;
  82.         for(int m=1; m<=a[3]; m++)
  83.             cout<<" ";
  84.         cout<<"★"<<endl;
  85.         if(a[c]>=57)
  86.         {
  87.             system("cls");
  88.             cout<<"賽馬場"<<"第"<<e<<"局"<<"由"<<j[c]<<"先馳得點"<<endl;
  89.             cout<<"---------------------------------------------------------|終點"<<endl;
  90.             for(int m=1; m<=a[0]; m++)
  91.                 cout<<" ";
  92.             cout<<"△"<<endl;
  93.             for(int m=1; m<=a[1]; m++)
  94.                 cout<<" ";
  95.             cout<<"▲"<<endl;
  96.             for(int m=1; m<=a[2]; m++)
  97.                 cout<<" ";
  98.             cout<<"☆"<<endl;
  99.             for(int m=1; m<=a[3]; m++)
  100.                 cout<<" ";
  101.             cout<<"★"<<endl;
  102.             if(c==h-1)
  103.             {
  104.                 cout<<endl<<"你贏得了"<<g<<"元"<<endl;
  105.                 money+=g;
  106.             }
  107.             else
  108.             {
  109.                 cout<<endl<<"你損失了"<<g<<"元"<<endl;
  110.                 money-=g;
  111.             }

  112.             break;
  113.         }
  114.         _sleep(50);

  115.     }
  116.     system("pause");
  117.     system("cls");
  118.     goto re;
  119. end:
  120.     cout<<"遊戲結束";
  121.     return 0;
  122. }
複製代碼

TOP

返回列表