Start each animal at square 1 of 70 squares (each square represents possible position. Use variables to keep track of position and if animals slip before square 1 then move them back to square one. Generate %age's by using a random number generator in the range of 1%26lt;= i %26lt;= 10.
Tortoise: Fast plod 1%26lt;= i %26lt;= 5 moves 3 squares right
Slip 6%26lt;= i %26lt;=7 moves 6 squares left
Slow Plod 8%26lt;= i %26lt;=10 moves 1 square right
Hare: sleep 1%26lt;= i%26lt;= 2 no move
Big Hop 3%26lt;= i%26lt;= 4 9 squares right
small hop 5%26lt;= i %26lt;=7 1 square right
Big Slip i == 8 12 squares left
small slip 9%26lt;= i%26lt;=10 2 squares left
Need to print a 70 position line on each loop showing position T (Tortoise), H (Hare). If both land on same square print "OUCH" at that position. all print position should be blank except for T, H and ouch. After each loop test if either animal %26gt;=70 if so print winner and end
C++ Basic arrays and pointers question: The Tortoise and the Hare?
Hmmmm, is this homework? Looks like you want someone to make this for you. How about you attempt it, then ask for help if you get stuck.
If you have no idea how to attempt it, I suggest you study the very basics, or ask your teacher.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment