questionwrite a program use a matrix represents


Question

Write a Program Use a matrix represents an island surrounded by water. Two bridges lead out of the island. A mouse is positioned on the black square. Write down a program to make the mouse take a walk across the island. The mouse is allowed to travel one square at a time, either horizontally or vertically. A chance number from 1 through 4 have to be used to decide that direction the mouse is to take. The mouse drowns when he hits the water; he breaks out when he enters a bridge. You might generate a random number up to 100 times. If mouse does not find his way by the hundredth try, he will die of starvation. Restart the mouse in a reinitialized array and go back and repeat the whole process. Count up the number of times he escapes, drowns, and starves.

Input File-

1. First input line - size of array, as well as border of water and bridges

2.Next N input lines-the rows of the two-dimensional array, where the positions containing negative numbers represent the water, the positions in the edge containing a 0 represent the bridges, the position containing a 1 represents the starting position of the mouse, and all other positions contain 0s.

Output-

1. A line stating whether mouse escaped, drowned, or starved

2. A line show the mouse's starting position and the position of two bridges

3. A map show the frequency of the mouse's visits to each location

 

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: questionwrite a program use a matrix represents
Reference No:- TGS0444109

Expected delivery within 24 Hours