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

TOP

返回列表