Mooshak Mouse
Mooshak the mouse has been placed in a maze.There is a huge chunk of cheese somewhere in the maze. The maze is represented as a two dimensional array of integers, where 0 represents walls.1 repersents paths where mooshak can move and 9 represents the huge chunk of cheese. Mooshak starts in the top left corner at 0. Write a method is Path of class Maze Path to determine if Mooshak can reach the huge chunk of cheese. The input to is Path consists of a two dimensional array gnd for the maze matrix. the method should return 1 if there is a path from Mooshak to the cheese.and 0 if not Mooshak is not allowed to leave the maze or climb on walls. EX: 8 by 8(8*8) matrix maze where Mooshak can get the cheese. 1 0 1 1 1 0 0 1 1 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 1 0 1 0 9 0 1 1 1 1 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 0 0 1 0 1 1 1 1 1 1 1 1 1
Input Format
The input to is Path consists of a two dimensional array size and the values for the maze matrix
Constraints
nil
Output Format
return 1 if there is a path and 0 if not
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int maze(int block[][100],int m,int i,int j){
if(i>m ||j>m )
return 0;
if(block[i][j]==9)
return 1;
int a= maze(block,m,i+1,j);
int b=maze(block,m,i,j+1);
if(a==1 || b==1 ){
return 1;
}
return 0;
}
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int m;
scanf("%d",&m);
int block[m][m];
for(int i=0;i<m;i++){
for(int j=0;j<m;j++){
scanf("%d",&block[i][j]);
}
}
printf("%d",maze(block,m,0,0));
return 0;
}