-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sudok
81 lines (74 loc) · 2.13 KB
/
Sudok
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
81
import java.util.*;
class sudoku
{
public static void main()
{
int i,j,k,l,p,q,w,e,r,t,y,c=0,s=0;
int arr[][]=new int[9][9];
Scanner sc=new Scanner(System.in);
System.out.println("Enter numbers");
for(i=0;i<=8;i++)
{
for(j=0;j<=8;j++)
{ arr[i][j]=sc.nextInt();
for(k=0;k<=8;k++)
{
for(l=0;l<=8;l++)
{
System.out.print(arr[k][l]);
}
System.out.println(" ");
}
}
}
for(i=0;i<=8;i++)
{
for(j=0;j<=8;j++)
{
s=s+arr[i][j];
}
if(s==45)
c++;
s=0;
}
for(j=0;j<=8;j++)
{
for(i=0;i<=8;i++)
{
s=s+arr[i][j];
}
if(s==45)
c++;
s=0;
}
s=0;
for(p=0;p<=8;p=p+3)
{ for(q=p;q<=p+2;q++)
{
for(w=0;w<=2;w++)
{
s=s+arr[q][w];
} }
if(s==45)
c++;
s=0;
for(e=p;e<=p+2;e++)
{
for(r=3;r<=5;r++)
{ s=s+arr[e][r];
}}if(s==45)
c++;
s=0;
for(t=p;t<=p+2;t++)
{
for(y=6;y<=8;y++)
{ s=s+arr[t][y];
}}if(s==45)
c++;
s=0;
}
if(c==27)
System.out.println("You win");
else
System.out.println("You lose");
}}