Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

need to write the function definitions to sudoku.h and write a program to test i

ID: 3659361 • Letter: N

Question

need to write the function definitions to sudoku.h and write a program to test it, here is what I have I need the remaining functions and the main program. The program should read puzzles from a .txt file and solve them //"sudoku.h" #include #include using namespace std; class sudoku { public: sudoku(); //default constructor //postcondition: grid is initialized to 0 sudoku(int g[][9]); //constructor //postcondition grid=g void initializeSudokuGrid(); //function to prompt the user to specify the numbers of //the partially filled grid void initiailizeSudokuGrid(int g[][9]); //function to initialize the grid to g //postcondition grid=g void printSudokuGrid(); //function to print the sudoku grid bool solveSudoku(); //function to solve the sudoku problem //postcondition: if a solution exists, then it returns true //otherwise it returns false bool findEmptyGridSlot(int &row, int &col); //function to determine if the grid slot specified by //row and col is empty //postsondition: returns true if gris[row][col]=0 bool canPlaceNum(int row, int col, int num); //function to determine if num can be placed in //grid[row][col] //postcondition: returns ture if num can be placed in //grid [row][col], otherwise returns false bool numAlreadyInRow(int row, int num); //function to determine if num is in grid[row][] //postcondition: returns true if num is in grid[row][], //otherwise it returns false bool numAlreadyInCol(int col, int num); //function to determine if num is in grid [row][] //postcondition: returns true if num is in grid[row][] //otherwise returns false bool numAlreadyInBox(int smallGridRow, int smallGridCol, int num); //function to determine if num is in the small grid //postcondition: returns true if num is in small grid //otherwise returns false. private: int grid[9][9]; }; //"sudoku.cpp" #include #include #include "sudoku.h" bool sudoku::solveSudoku() { int row, col; if (findEmptyGridSlot(row, col)) { for (int num = 1; num <= 9; num++) if (canPlaceNum(row, col, num)) { grid[row][col] = num; if (solveSudoku()) // recursive call return true; grid[row][col]=0; } } return false; //backtrack } else return true; //there are no empty slots }

Explanation / Answer

#include #include int main() { int t,i,j,k,l,m,n,sum,temp,r,q,p,x,y,count; scanf("%d",&t); while(t!=0) { scanf("%d",&n); sum=n*(n+1)/2; int a[n+1][n+1]; for(i=0;i