# Hi!

Discussion in 'Meet and Greet' started by Angelli, Dec 5, 2012.

Not open for further replies.
1. ### AngelliNew Member

Joined:
Dec 5, 2012
Messages:
4
0
Trophy Points:
0
I just need a help to make this program. Please kindly help me make this one 'coz I'm a newbie in this C Programming language.

A drunken cockroach is placed on the middle of a tile floor in a rectangular room that has N by M tiles. Searching for an aspirin, the bug wanders aimlessly from tile to tile throughout the room. Assuming that the cockroach may move from his present tile to any of the eight tiles surrounding him (unless he is against a wall) with equal probability, write a MODULARIZED program that stimulates the bugâ€™s search for the aspirin.

Input N and M from the keyboard. The aspirin is randomly placed on a tile. Randomly generate integers from 1 to 8 to determine the cockroachâ€™s next move. Use the following convention.

Random number Bugâ€™s direction

1 North

2 Northeast

3 East

4 Southeast

5 South

6 Southwest

7 West

8 Northwest

As the bug wanders looking for aspirin, store successive integers in a FLOOR array indicating the tiles he crawled over. You will need to check if he bumps into walls and may have to generate additional numbers to get him on his way again.

Output is to consist of the floor dimensions (N and M), the initial location of the cockroach, the location of the aspirin, and a table representing the floor with his random walk recorded. I expect appropriate headings and a nicely formatted table in the output. I expect commenting, Indenting, and the use of white space. Test appropriately.

Requirements:

1. Use a two-dimensional array for this problem. Make the program solve by showing every possible solution.

Joined:
Dec 2, 2008
Messages:
1,267