//base case
if(i==n and j==m)
{
output[i][j]=1;
//print path
for(int x=0;x<=n;x++)
{
for(int y=0;y<=m;y++)
{
cout<<output[x][y]<<" ";
}
cout<<endl;
}
return true;
}
if(i>n || j>m){
return false;
}
if(input[i][j]=='X'){
return false;
}
output[i][j]=1;
bool downSuccess = ratProblem(input,output,i+1,j,n,m);
bool rightSuccess = ratProblem(input,output,i,j+1,n,m);
output[i][j]=0;
if(downSuccess || rightSuccess){
return true;
}
return false;
}
The above code prints multiple solutions but I want only one . I am unable to make the needed changes.