Question: Write A C++ programme with this following instruction Question 3: Tom and Jerry [8] Category: Medium Izaan, a little boy, loves to watch Tom &

 Write A C++ programme with this following instruction Question 3: Tom

Write A C++ programme with this following instruction

Question 3: Tom and Jerry [8] Category: Medium Izaan, a little boy, loves to watch Tom & Jerry. He loves this cartoon so much that he dreams of this cartoon character while sleeping. One day, he saw in his dream that Tom caught Jerry and imprison Jerry in a cage that looks like a two-dimensional matrix as shown in the following image which has only one way to escape and Jerry wanted to escape from that matrix. Izaan wanted to help Jerry in his dream, but he could not. So that Izaan was crying, suddenly Orni, the aunt of Izaan, came and asked him about the matter. Izaan clearly remembered the pattern of the cage. Now, Izaan wants Orni to show the path for Jerry to escape from the cage so that he can help Jerry next time or report that it's not possible to escape from the cage. Can you help Orni to solve this problem? ESCAPE You are given a nxm dimensional matrix, where n represents the number of row and m represents the number of columns. The matrix contains 4 integers from 0 to 3. 0: Escape 1: The current position of Jerry 2: Danger Zone for Jerry and Jerry won't go those indices 3: Safe Zone You have to print the path by which Jerry can escape from the cage or report that it's impossible. If it's impossible to escape from the case print -1. Jerry can move in four directions only. Left, Right, Up and Down. 5

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!