Mazepath_D(count_Pruint/)

what is wrong in my code

include

using namespace std;

void mpath(char maze[],int m,int n,int i,int j,int k,int &count){
//base case
if(i==m and j==n){
maze[k]=’\0’;
cout<<maze<<" ";
count++;
return;
}

//recursive case
if(i<m and j<n){
    if(i+1<m){
        maze[k]='V';
        mpath(maze,m,n,i+1,j,k+1,count);
    }
     if(j+1<n){
        maze[k]='H';
        mpath(maze,m,n,i,j+1,k+1,count);
    }
     if(i+1<m and j+1<n){
        maze[k]='D';
        mpath(maze,m,n,i+1,j+1,k+1,count);
    }
}

}

int main(){
int m,n;
cin>>m>>n;

char maze[100];
int count = 0;
mpath(maze,m-1,n-1,0,0,0,count);
cout<<count<<endl;
return 0;

}

hi @abhinavssr2003_eab0717682969e5c refer this https://www.youtube.com/watch?v=bE1ut7k9Gms detailed explanation is there, u need vis array

But sir what is the issue that is occur
ring in my code?

@abhinavssr2003_eab0717682969e5c u r visiting same cell again and again, she will explain this issue saying many student forgets watch that vid its very informative u wont mess up again in these type of questions

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

please send me the sample code

please send me the sample code…mine is not correct

got the answerr thanks

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.