Help with Basic Arrays and Pointers Bloodshed Dev-C++?
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 who wins and terminate the program.
Help with C++?
You need a condition to reset the animals to square 1 if they are %26lt; 1.
Also, the while loop test for (hNum %26lt; 70 || tNum %26lt; 70) is not right since you are continuing the race even after one of them has won it. You need %26amp;%26amp; instead with appropriate final print statements.
Your "cout" statements in the for loop needs to account for a space if there is nothing in that position. You also need appropriate "endl"s.
Keep in mind that due to random number usage, the animals might take forever to reach the end line.
Reply:Could not figure it out, if you are still stuck, may be you can contact a C++ expert live at website like http://oktutorial.com/ .
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment