返回列表 發帖
  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.     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.     system("pause");
  57.     system("cls");
  58.     while(true)
  59.     {
  60.         system("cls");
  61.         int c=rand()%4;
  62.         if(a[c]>=57)
  63.         {
  64.             cout<<"賽馬場"<<"第"<<e<<"局"<<"由"<<j[c]<<"先馳得點"<<endl;
  65.             break;
  66.         }
  67.         cout<<"賽馬場"<<"第"<<e<<"局"<<endl;
  68.         cout<<"---------------------------------------------------------|終點"<<endl;
  69.         a[c]+=3;
  70.         for(int m=1; m<=a[0]; m++)
  71.             cout<<" ";
  72.         cout<<"△"<<endl;
  73.         for(int m=1; m<=a[1]; m++)
  74.             cout<<" ";
  75.         cout<<"▲"<<endl;
  76.         for(int m=1; m<=a[2]; m++)
  77.             cout<<" ";
  78.         cout<<"☆"<<endl;
  79.         for(int m=1; m<=a[3]; m++)
  80.             cout<<" ";
  81.         cout<<"★"<<endl;
  82.         _sleep(50);

  83.     }
  84.     cout<<"---------------------------------------------------------|終點"<<endl;
  85.     for(int m=1; m<=a[0]; m++)
  86.         cout<<" ";
  87.     cout<<"△"<<endl;
  88.     for(int m=1; m<=a[1]; m++)
  89.         cout<<" ";
  90.     cout<<"▲"<<endl;
  91.     for(int m=1; m<=a[2]; m++)
  92.         cout<<" ";
  93.     cout<<"☆"<<endl;
  94.     for(int m=1; m<=a[3]; m++)
  95.         cout<<" ";
  96.     cout<<"★"<<endl;
  97.     system("pause");
  98.     system("cls");
  99.     goto re;

  100.     return 0;
  101. }
複製代碼

TOP

返回列表