返回列表 發帖
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
    int horse1=0,horse2=0,horse3=0,horse4=0,random=0;
    int money=0,buyin=0,choise=0,bet=0,player=0;
    int times=0;
void start()
{
   while(horse1!=45&&horse2!=45&&horse3!=45&&horse4!=45)
    {
     random=rand()%4;
     if(random==0)
     horse1++;
     if(random==1)
     horse2++;
     if(random==2)
     horse3++;
     if(random==3)
     horse4++;
     cout<<"比賽進行中"<<endl;
     cout<<"---------------------------------------------| 終點"<<endl;
     for(int i=1; i<=horse1; i++)
     cout<<" ";  
     cout<<"Q"<<endl;
     for(int i=1;i<=horse2;i++)
     cout<<" ";
     cout<<"∮"<<endl;  
     for(int i=1;i<=horse3;i++)
     cout<<" ";
     cout<<"㊣"<<endl;   
     for(int i=1;i<=horse4;i++)
     cout<<" ";
     cout<<"♂"<<endl;   
     system("cls");                                       
    }
    times++;
    cout<<"比賽結束!由";
    if(horse1==45)
    cout<<"Q獲勝~~"<<endl;
    else if(horse2==45)
    cout<<"∮獲勝~~"<<endl;
    else if(horse3==45)
    cout<<"㊣獲勝~~"<<endl;
    else if(horse1=4==45)
    cout<<"♂獲勝~~"<<endl;
    cout<<"---------------------------------------------| 終點"<<endl;
    for(int i=1; i<=horse1; i++)
    cout<<" ";  
    cout<<"Q"<<endl;
    for(int i=1;i<=horse2;i++)
    cout<<" ";
    cout<<"∮"<<endl;  
    for(int i=1;i<=horse3;i++)
    cout<<" ";
    cout<<"㊣"<<endl;   
    for(int i=1;i<=horse4;i++)
    cout<<" ";
    cout<<"♂"<<endl;
    choise=0;
    system("pause");   
}
int main()
{
   
    while(true)
    {
   
    system("cls");
    while( choise== 0 or choise ==1)
    {
    srand(time(NULL));
    system("cls");
    cout<<"人山人海人見人愛  賽馬場"<<endl;
    cout<<"---------------------------------------------|終點"<<endl;
    cout<<"Q"<<endl;
    cout<<"∮"<<endl;
    cout<<"㊣"<<endl;
    cout<<"♂"<<endl;
   
    cout<<"可用餘額:"<<money<<"元"<<endl;
    cout<<"(1)買入(2)下注(3)離開,請選擇:";
    cin>>choise;
    if(choise==1)
    {
     cout<<"請輸入價錢:";
     cin>>buyin;         
     money=+buyin;   
    }
    else if(choise==2)
    {
     cout<<"下注:";
     cin>>bet;
     if(money>bet)
     {
      money=money-bet;
      cout<<"請選擇下注馬匹1)Q(2)∮(3)㊣(4)♂";
      cin>>player;
      cout<<"比賽即將進行..."<<endl;
      start();                  
     }
     else{
      cout<<"錢不夠啦!!!"<<endl;
      break;   
     }
     
    }
    else if(choise==3)
    {
     break;   
    }
}
     
   
    system("pause");
    system("cls");
   
   
      
    }

     system("pause");
     return 0;
}

TOP

返回列表