Can you please specify the error in my code?
#include
using namespace std;
static int ways=0;
bool isSafe(int **board,int i,int j,int n)
{
for(int row=0;row<i;row++)
{
if(board[row][j]==1)
return false;
}
int x=i;
int y=j;
while(x>=0 && y>=0)
{
if(board[x][y]==1)
return false;
x--;
y--;
}
x=i;
y=j;
while(x>=0 && y<n)
{
if(board[x][y]==1)
return false;
x--;
y++;
}
return true;
}
bool solveNQueen(int **board,int i,int n,int ways)
{
if(i==n)
{
ways++;
cout<<ways;
return false;
}
for(int j=0;j<n;j++)
{
if(isSafe(board,i,j,n))
{
board[i][j]=1;
bool queenRakhPaaye=solveNQueen(board,i+1,n,ways);
if(queenRakhPaaye)
{
return true;
}
board[i][j]=0;
}
}
return false;
}
int main()
{
int n,i,j;
cin>>n;
int *board=new int[n];
for(i=0;i<n;i++)
board[i]=new int[n];
for(i=0;i<n;i++)
for(j=0;j<n;j++)
board[i][j]=0;
solveNQueen(board,0,n,ways);
}