My code is giving me run time error don’t know why can you help me. What’s wrong with my code?
Link to my code
My code is giving me run time error don’t know why can you help me. What’s wrong with my code?
Link to my code
Pls add comments in your code so tht I could understand it
Done added the comments.
Plz help
The approach you are trying to use in the code is not correct…you are supposed to take a bool function, and a solution matrix values…
bool ratmaze(char maze[1001][1001],int i,int j,int N,int M)
{
if(i==N && j==M)
{
solution[i][j]=1;
for(int x=0;x<=N;x++)
{
for(int y=0;y<=M;y++)
{
cout<<solution[x][y]<<" ";
}
cout<<endl;
}
return true;
}
if(visited[i][j])
{
return false;
}
solution[i][j]=1;
bool rightSuccess=ratmaze(maze,i,j+1,N,M);
if(rightSuccess==true)
{
return true;
}
bool downSuccess=ratmaze(maze,i+1,j,N,M);
if(downSuccess==true)
{
return true;
}
solution[i][j]=0;
return false;
}
This is the approach you need to use…