Question: #include #include using namespace std; void backtrack(int &c){ c--; if (c==-1) { exit(1); } } void print(int cross[]) { static int count = 0; cout

 #include #include using namespace std; void backtrack(int &c){ c--; if (c==-1)

#include #include using namespace std;

void backtrack(int &c){ c--; if (c==-1) { exit(1); } }

void print(int cross[]) { static int count = 0; cout

}

bool test(int cross[], int c ){ for(int i=0; i

int main() { int c=0; int cross[8]={}; int checkList[8][5] = { {-1}, {0,-1}, {1,-1}, {0,1,2,-1}, {1,2,3,-1}, {2,4,-1}, {0,3,4,-1}, {3,4,5,6,-1}, }; while(true){ while(c8) { cross[c]=0; backtrack(c); continue; } for(int i=0; i

There my question and code. I don't know why i cannot get output. Can someone help me? Thank you!!!

Eight Numbers in a Cross In the solution to this problem, use the backtracking scheme that we covered in class. Write a program which allocates the integers 1-8 to the squares in the figure above, subject to the restrictions that no two adjacent squares contain consecutive integers. By adjacent we mean vertically, horizontally, or diagonally

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!