https://ide.codingblocks.com/s/131615…
Please check whats wrong in it…Iam not getting correct output…Check the code and explain.
N queens problem
use recursion to solve this problem
I told you to check my code and figure out what is wrong.please dont answer this way,I know we can solve in recursion…please check my code
if(f==0){
i–;
board[i][prevJ[i]-1]=0;
break;
}
this break through you out of all loops means out of function;
also there are many boundary case which are don’t consider
you only check for one diagonal element
for Ex
0 1 0 0 0
0 0 0 1 0
1 0 0 0 0
0 0 0 0 1
your code consider it correct but last 1 is diagonal to first one. and you check only first one step in diagonal