It does not print output
please help
#include
using namespace std;
bool noRakhPaye(int inp[9][9], int i, int j, int no){
for (int x=1;x<=9; x++)
{
if(inp[x][j] == no or inp[i][x] == no)
return false;
}
int sx = (i/3)*3;
int sy = (j/3)*3;
for (int a = sx; a<sx+3; a++)
{
for(int b = sy; b<sy+3; b++){
if(inp[a][b] == no)
return false;
}
}
return true;
}
bool solveSudoku(int inp[9][9], int i, int j){
if (i==9)
{
for (int i = 0; i < 9; ++i)
{
for(int j = 0;j<9; j++){
cout<<inp[i][j]<<" ";
}
cout<<endl;
}
return true;
}
if(j == 9){
return solveSudoku(inp,i+1, 0);
}
if(inp[i][j]!=0){
return solveSudoku(inp,i, j+1);
}
for (int no = 1; no<=9; no++)
{
if(noRakhPaye(inp,i,j,no)){
inp[i][j] = no;
bool couldWeSolve = solveSudoku(inp, i, j+1);
if(couldWeSolve == true)
return true;
}
}
inp[i][j] = 0;
return false;
}
int main(){
int sudoku[][9] =
{ {3, 0, 6, 5, 0, 8, 4, 0, 0},
{5, 2, 0, 0, 0, 0, 0, 0, 0},
{0, 8, 7, 0, 0, 0, 0, 3, 1},
{0, 0, 3, 0, 1, 0, 0, 8, 0},
{9, 0, 0, 8, 6, 3, 0, 0, 5},
{0, 5, 0, 0, 9, 0, 6, 0, 0},
{1, 3, 0, 0, 0, 0, 2, 5, 0},
{0, 0, 0, 0, 0, 0, 0, 7, 4},
{0, 0, 5, 2, 0, 6, 3, 0, 0} };
solveSudoku(sudoku, 0, 0);
return 0;
}