Hi i want to make a program that simulates a hare racing a rabbit. The actual program would look like this on the screen.
|H===================|
|R===================|
the letters represent rabbit and hare respectivly and advance down the track based on a random number genearator from 1 to 50. If it geneartes a 25 or greater the letter moves a space and if its lower it stays in place. It does this for both tracks until one finishes.
the only problem is i cant get the letters to move. help?
int main()
{
string track = "|===============|";
int randNum;
//rand num gen
srand(int(time(0)));
randNum = 50 + rand() % (50 - 1 + 1);
//determine whether rabbit moves
while ( randNum >= 25)
{
for(int x = 1; x < 17; x++)//This is the part i cant figure :/
{
track.insert(x, 'R');//<--- no idea what to do
}
}
cout << track << endl;
return 0;
}
i didnt include the headers
theres all i have, just working on the rabbit track. im a beginner. like i said i just dont know how to get the letter to move. Ive been experimenting with different things for a couple days.
Yes. I'm not going to code the whole solution for you. I've provided you with a basic rundown on how to achieve the moving across the track as you have inquired about.