-
Notifications
You must be signed in to change notification settings - Fork 1
/
6_14_sudoku.cpp
80 lines (77 loc) · 1.41 KB
/
6_14_sudoku.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <iostream>
using namespace std;
// Create class for sudoku-checker
/*
class SudokuChecker {
bool columnChecker(vector<vector<int>>& S, const int& columnNum);
// similarly rowChecker
// and then blockChecker
bool blockChecker(vector<vector<int>>& S, const int& i, const int& j);
// (i,j) is the bottom-left coordinate of the block
// Fill these methods, then create s SudokuChecker class-object in main and call its methods appropriately
}
*/
int main()
{
int arr[9][9];
for(int i=0;i<9;i++)
{
for(int j=0;j<9;j++)
{
cin >> arr[i][j];
}
}
int check[90];
for(int i=0;i<90;i++)
check[i]= 0;
int m, flag = 0;
for(int i=0;i<9;i++)
{
for(int j=0;j<9;j++)
{
if(arr[i][j])
{
m = (i/3)*3 + j/3;
check[arr[i][j] + m*10] += 1;
if(check[arr[i][j] + m*10] > 1)
flag = 1;
}
}
}
if(!flag)
{
for(int i=0;i<90;i++)
check[i]= 0;
for(int i=0;i<9;i++)
{
for(int j=0;j<9;j++)
{
if(arr[i][j])
{
check[arr[i][j] + i*10] += 1;
if(check[arr[i][j] + i*10] > 1)
flag = 1;
}
}
}
}
if(!flag)
{
for(int i=0;i<90;i++)
check[i]= 0;
for(int i=0;i<9;i++)
{
for(int j=0;j<9;j++)
{
if(arr[j][i])
{
check[arr[j][i] + i*10] += 1;
if(check[arr[j][i] + i*10] > 1)
flag = 1;
}
}
}
}
if(!flag)
cout << "Everything's Perfect";
}