Hello. I'm a high school student (Jr.) taking C++ (I'm pretty new to it).
I have to do a horse race program that's due tonight at 12am.
I have the horse race portion down pat but I'm very confused with how to show the places of the horses when the race is complete. Any help would be appreciated. Here's the program (the place function is what I made so far to try and display the places of the horses):
Code:
#include<iostream.h>
#include<conio.h>
#include<lvp\random.h>
void drawtrack()
{
clrscr();
cout<<" ------------------------------------------------------------"<<endl;
cout<<"1|------------------------------------------------------------|"<<endl;
cout<<"2|------------------------------------------------------------|"<<endl;
cout<<"3|------------------------------------------------------------|"<<endl;
cout<<"4|------------------------------------------------------------|"<<endl;
cout<<" ------------------------------------------------------------"<<endl;
}
void changehorse(int horsenum, int y)
{
gotoxy(y+2,horsenum+1);
cout<<"-H"<<endl;
}
void movehorse(int horsenum,int &y)
{
if(1+random(100)>50 && y<60) {
changehorse(horsenum,y);
y++;
}
}
void place()
{
int p,y,horse1,horse2,horse3,horse4,horsenum;
if(horse1=60)
cout<<"horse 1: 1st place"<<endl;
else(horse1<60);
if(horse2=60)
cout<<"horse 2: 1st place"<<endl;
else(horse2<60);
if(horse3=60)
cout<<"horse 3: 1st place"<<endl;
else(horse3<60);
if(horse4=60)
cout<<"horse 4: 1st place"<<endl;
else(horse4<60);
}
void main()
{
clrscr();
randomize();
drawtrack();
place();
int horse1=1;
int horse2=1;
int horse3=1;
int horse4=1;
while(horse1<60||horse2<60||horse3<60||horse4<60)
{
movehorse(1,horse1);
movehorse(2,horse2);
movehorse(3,horse3);
movehorse(4,horse4);
for(long pp=1;pp<=10000000;pp++);
}
}