mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
fix: sudoku_solve.cpp
This commit is contained in:
parent
2502bd11b6
commit
13b5b9b829
@ -1,6 +1,6 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
bool isPossible(int *mat[][9], int i, int j, int no, int n) {
|
bool isPossible(int mat[][9], int i, int j, int no, int n) {
|
||||||
/// Row or col nahin hona chahiye
|
/// Row or col nahin hona chahiye
|
||||||
for (int x = 0; x < n; x++) {
|
for (int x = 0; x < n; x++) {
|
||||||
if (mat[x][j] == no || mat[i][x] == no) {
|
if (mat[x][j] == no || mat[i][x] == no) {
|
||||||
@ -23,7 +23,7 @@ bool isPossible(int *mat[][9], int i, int j, int no, int n) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printMat(int *mat[][9], int n) {
|
void printMat(int mat[][9], int n) {
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < n; j++) {
|
||||||
std::cout << mat[i][j] << " ";
|
std::cout << mat[i][j] << " ";
|
||||||
@ -38,7 +38,7 @@ void printMat(int *mat[][9], int n) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool solveSudoku(int *mat[][9], int i, int j) {
|
bool solveSudoku(int mat[][9], int i, int j) {
|
||||||
/// Base Case
|
/// Base Case
|
||||||
if (i == 9) {
|
if (i == 9) {
|
||||||
/// Solve kr chuke hain for 9 rows already
|
/// Solve kr chuke hain for 9 rows already
|
||||||
|
Loading…
Reference in New Issue
Block a user