Escolar Documentos
Profissional Documentos
Cultura Documentos
h>
#include <stdbool.h>
#define N 3
#define SIZE (N * N)
if (resolverSudoku(tabuleiro)) {
return true; // Sudoku resolvido
}
int main() {
int tabuleiro[SIZE][SIZE] = {
{ 5, 3, 0, 0, 7, 0, 0, 0, 0 },
{ 6, 0, 0, 1, 9, 5, 0, 0, 0 },
{ 0, 9, 8, 0, 0, 0, 0, 6, 0 },
{ 8, 0, 0, 0, 6, 0, 0, 0, 3 },
{ 4, 0, 0, 8, 0, 3, 0, 0, 1 },
{ 7, 0, 0, 0, 2, 0, 0, 0, 6 },
{ 0, 6, 0, 0, 0, 0, 2, 8, 0 },
{ 0, 0, 0, 4, 1, 9, 0, 0, 5 },
{ 0, 0, 0, 0, 8, 0, 0, 7, 9 }
};
printf("Tabuleiro inicial:\n");
imprimirTabuleiro(tabuleiro);
if (resolverSudoku(tabuleiro)) {
printf("Sudoku resolvido:\n");
imprimirTabuleiro(tabuleiro);
} else {
printf("Não há solução para o Sudoku.\n");
}
return 0;
}