-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sudoku solver.cpp
63 lines (60 loc) · 1.29 KB
/
Sudoku solver.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
Program : Sudoku Solver
Description : It is a sudoku solver program. It solves the sudoku entered by the user of 9X9 matrix.
Author : Akshat Jain
Roll Number : 1918006
Email : [email protected]
github : github.com/akshatprogrammer
*/
#include<iostream>
#include<conio.h>
#include"game.h"
#include"usedin.h"
using namespace std;
void inputGrid(int grid[9][9])
{
for(int i=0;i<9;i++)
{
for(int j=0;j<9;j++)
{
cin >> grid[i][j];
}
}
}
void printGrid(int grid[9][9])
{
cout << "Solved Sudoku is ->\n";
for (int i = 0; i < 9; i++)
{
for (int j = 0; j < 9; j++)
cout << grid[i][j] << " ";
cout << endl;
}
}
int main()
{
cout << "\t\t\t\tWelcome to Sudoku Solver by Akshat Jain\nPress any key to continue\nPress 0 to exit\n";
int ch;
cin >> ch;
system("cls");
if(ch==0)
cout << "\n\n\n\n\n\n\t\t\t\tThank You!!";
else{
int grid[9][9];
cout << "Enter the Sudoku to be solve -> " << endl;
inputGrid(grid);
system("cls");
if (Sudoku(grid) == true)
{
printGrid(grid);
cout << "\n\n\nEnter any key to exit ";
cin >> ch;
system("cls");
cout << "Thank You";
exit(0);
}
else
cout << "No solution exists";
}
return 0;
}