返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int balance=0;
  7.     start:
  8.     srand(time(NULL));
  9.     int space[]={0,0,0,0};
  10.     int option, money;
  11.     system("cls");
  12.     cout<<"賽馬場"<<endl;
  13.     cout<<"------------------------------------------------------------------------------| 終點"<<endl;
  14.     cout<<"◆"<<endl;
  15.     cout<<"★"<<endl;
  16.     cout<<"▲"<<endl;
  17.     cout<<"●"<<endl;
  18.     cout<<"可用餘額: "<<balance<<"元"<<endl<<endl;
  19.     cout<<"(1)買入  (2)下注  (3)離開  請選擇: ";
  20.     cin>>option;
  21.    
  22.     if (option==1)
  23.     {    cout<<"買入: ";
  24.         cin>>money;
  25.         balance+=money;   //balance=balance+buyin
  26.         goto start;
  27.     }
  28.     int tmp;
  29.     cout<<"下注:";
  30.     cin>>tmp;
  31.     if (tmp>money)
  32.     {
  33.             cout<<"可用餘額不足!請先買入"<<endl;
  34.            system("pause");
  35.            goto start;
  36.            }else if(tmp<money)
  37.            {
  38.                  cout<<"(1)◆ (2)★ (3)▲ (4)●請選擇: "<<endl;
  39.            }
  40.     system("pause");
  41.     while (true)
  42.     {
  43.           int r=rand()%4;
  44.           space[r]++;
  45.           if(space[r]==74)
  46.                break;
  47.           cout<<"比賽進行中"<<endl;
  48.           cout<<"--------------------------------------------------------------------------| 終點"<<endl;
  49.              for(int i=0;i<=space[0];i++)
  50.              {
  51.                   cout<<" ";
  52.              }
  53.              cout<<"◆"<<endl;
  54.              for(int j=0;j<=space[1]; j++)
  55.              {
  56.                   cout<<" ";
  57.              }
  58.              cout<<"★"<<endl;
  59.              for(int j=0;j<=space[2];j++)
  60.              {
  61.                   cout<<" ";
  62.              }
  63.              cout<<"▲"<<endl;
  64.              for(int j=0;j<=space[3];j++)
  65.              {     
  66.                    cout<<" ";
  67.              }
  68.              cout<<"●"<<endl;
  69.              system("cls");
  70.      }
  71.          cout<<"比賽結束! 由 ";
  72.     if(space[0]==74)
  73.         cout<<"◆";
  74.     else if(space[1]==74)
  75.         cout<<"★";
  76.     else if(space[2]==74)
  77.         cout<<"▲";
  78.     else
  79.         cout<<"●";
  80.     cout<<" 先到達終點!"<<endl;

  81.            cout<<"比賽結束"<<endl;
  82.           cout<<"--------------------------------------------------------------------------| 終點"<<endl;
  83.              for(int i=0;i<=space[0];i++)
  84.              {
  85.                   cout<<" ";
  86.              }
  87.              cout<<"◆"<<endl;
  88.              for(int j=0;j<=space[1]; j++)
  89.              {
  90.                   cout<<" ";
  91.              }
  92.              cout<<"★"<<endl;
  93.              for(int j=0;j<=space[2];j++)
  94.              {
  95.                   cout<<" ";
  96.              }
  97.              cout<<"▲"<<endl;
  98.              for(int j=0;j<=space[3];j++)
  99.              {     
  100.                    cout<<" ";
  101.              }
  102.              cout<<"●"<<endl;
  103.              system("pause");
  104.              goto start;
  105.     system("pause");
  106.     return 0;   
  107. }
複製代碼

TOP

返回列表