Well, they basically told you everything you need to know already.
Have a variable "hare" and one "tortoise", they save the positions. Have a while(true) loop. This is the running loop. Before you enter it, print:
cout << "BANG !!!!!\nAND THEY'RE OFF !!!!!" << endl;
In the loop you get a random number (rand() from stdlib.h)(use the modulo % operator to limit the range). Don't forget to init the random number generator with srand, usually by feeding it with the output of time(NULL) or GetTickCount().
Use the number to determine what the hare does, adjust it's position. Then get a second random number and use it to determine what the tortoise does. Then evaluate the results (tortoise bites rabbit, wins, loses, tie, nothing). When the race shall end, use the break statement.
The last part of the loop should be some delay, you can use the WinAPI Sleep(milliseconds) for this. I recommend 950 milliseconds delay.
The printing itself should be easy. Determine the lower of the two positions. Use setw (iomanip.h) to position the cursor at this pos. Print the character of the current animal (or OUCH!). The feed setw a number determined by this:
cout << setw( larger - smaller - 1) << letterOfAnimal;
The complete statement would therefore be
cout << setw(smaller);
if(smaller == larger)
cout << "OUCH!" << endl;
else
cout << letterOfSlowAnimal << setw(larger - smaller - 1) <<
letterOfFastAnimal;
This will print the track. Then go for another round.
All the buzzt CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.