Question: #include using namespace std; int fib ( int foo ) { if ( ( foo = = 1 ) | | ( foo = =

#include
using namespace std;
int fib(int foo)
{
if ((foo ==1)||(foo ==2))
return 1;
else
return fib(foo-1)+ fib(foo-2);
}
void printB(int b[9][9])
{
for (int i =0; i <9; ++i)
{
for (int j =0; j <9; ++j)
{
cout << b[i][j]<<"";
}
cout << endl;
}
}
bool find_gap(int b[9][9], int &x, int &y)
{
for (x =0; x <9; ++x)
for (y =0; y <9; ++y)
if (b[x][y]==0)
return true;
return false;
}
bool ok_row_col(int b[9][9], int x, int y, int try_number)
{
for (int i =0; i <9; ++i)
{
if ((b[x][i]== try_number)||(b[i][y]== try_number))
return false;
}
return true;
}
bool solve(int board[9][9])
{
int x, y;
if (find_gap(board, x, y))
{
int b_copy[9][9];
for (int i =0; i <9; ++i)
for (int j =0; j <9; ++j)
b_copy[i][j]= board[i][j];
// try a move
for (int try_number =1; try_number <=9; ++try_number)
{
if (ok_row_col(b_copy, x, y, try_number))
{
b_copy[x][y]= try_number;
if (solve(b_copy))
return true;
}
}
// if out of moves, return false;
return false;
}
else
{
// check if solution is valid
// if valid, return true;
}
}
int main()
{
// cout << fib(10);
int board[9][9];
for (int i =0; i <9; ++i)
for (int j =0; j <9; ++j)
board[i][j]=0;
board[2][3]=6;
printB(board);
solve(board);
return 0;
}
complete the solution checker.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!