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

TOP

返回列表