返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n=1, balance=0;
  7.     re:
  8.     int a=0, b=0, c=0, d=0, r , option, buyin, bet;
  9.     system("cls");
  10.     cout<<"「穩賺不賠」賽馬場  <第"<<n<<"場>"<<endl;
  11.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  12.     cout<<"★1☆"<<endl;
  13.     cout<<"☆2★"<<endl;
  14.     cout<<"★3☆"<<endl;
  15.     cout<<"☆4★"<<endl<<endl;
  16.     cout<<"可用餘額: "<<balance<<"元"<<endl<<endl;
  17.     cout<<"(1)買入  (2)下注  (3)離開  請選擇: ";
  18.     cin>>option;
  19.     if(option==1)
  20.     {
  21.         cout<<"買入: ";
  22.         cin>>buyin;
  23.         balance=balance+buyin;
  24.         goto re;
  25.     }
  26.     else if(option==2)
  27.     {
  28.          if(balance==0)
  29.         {
  30.             cout<<"可用餘額不足! 請先買入!"<<endl<<endl;
  31.             system("pause");
  32.             goto re;
  33.         }
  34.         cout<<"下注: ";
  35.         cin>>bet;
  36.         if(bet>balance)
  37.         {
  38.             cout<<"可用餘額不足! 請先買入!"<<endl<<endl;
  39.             system("pause");
  40.             goto re;
  41.         }
  42.         else
  43.         {
  44.             cout<<endl<<"(1)1號 (2)2號 (3)3號 (4)4號  請選擇: ";
  45.             cin>>option;
  46.             cout<<"比賽即將開始..."<<endl<<endl;
  47.             system("pause");
  48.         }
  49.     }
  50.     else if(option==3)
  51.     {
  52.         goto end;
  53.     }
  54.     else
  55.     {
  56.        cout<<"輸入錯誤!"<<endl;
  57.        system("pause");
  58.        goto re;
  59.     }
  60.     system("cls");
  61.     srand(time(NULL));
  62.     while(a!=70 && b!=70 && c!=70 && b!=70)
  63.     {
  64.         r=rand()%4;
  65.         if(r==0)
  66.            a++;
  67.         else if(r==1)
  68.            b++;
  69.         else if(r==2)
  70.            c++;
  71.         else
  72.            d++;
  73.         cout<<"比賽進行中..."<<endl;
  74.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  75.         for(int i=1; i<=a; i++)
  76.            cout<<" ";
  77.         cout<<"★1☆"<<endl;
  78.         for(int i=1; i<=b; i++)
  79.            cout<<" ";
  80.         cout<<"☆2★"<<endl;
  81.         for(int i=1; i<=c; i++)
  82.            cout<<" ";
  83.         cout<<"★3☆"<<endl;
  84.         for(int i=1; i<=d; i++)
  85.            cout<<" ";
  86.         cout<<"☆4★"<<endl;   
  87.         system("cls");   
  88.     }   
  89.     if(a>b && a>c && a>d)
  90.          cout<<"比賽結束,由1號選手先馳得點"<<endl;
  91.     if(b>a && b>c && b>d)
  92.          cout<<"比賽結束,由2號選手先馳得點"<<endl;
  93.     if(c>a && c>b && c>d)
  94.          cout<<"比賽結束,由3號選手先馳得點"<<endl;
  95.     if(d>a && d>b && d>c)
  96.          cout<<"比賽結束,由4號選手先馳得點"<<endl;
  97.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  98.     for(int i=1; i<=a; i++)
  99.         cout<<" ";
  100.     cout<<"★1☆"<<endl;
  101.     for(int i=1; i<=b; i++)
  102.         cout<<" ";
  103.     cout<<"☆2★"<<endl;
  104.     for(int i=1; i<=c; i++)
  105.         cout<<" ";
  106.     cout<<"★3☆"<<endl;
  107.     for(int i=1; i<=d; i++)
  108.         cout<<" ";
  109.     cout<<"☆4★"<<endl;
  110.     system("pause");
  111.     n++;
  112.     goto re;
  113.     end:
  114.     system("pause");
  115.     return 0;   
  116. }
複製代碼

TOP

返回列表