-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathend.cpp
More file actions
66 lines (56 loc) · 741 Bytes
/
end.cpp
File metadata and controls
66 lines (56 loc) · 741 Bytes
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
int end(int array[],int input,int parity)
{
int i,j,k;
int x,y;
int toggle;
int matrix[100][100];
for(i=0;i<n;i++)
for(j=0;j<n;j++)
matrix[i][j]=-1;
x = input/n;
y = input%n;
j = 0;
for(i=parity;i<n;i+=2)
{
if(array[i]/n == x)
j++;
}
if(j == n)
return 0;
j=0;
for(i=parity;i<n;i+=2)
{
if(array[i]%n == y)
j++;
}
if(j==n)
return 0;
j=0;
for(i=0;i<n*n;i++)
{
x=array[i]/n;
y=array[i]%n;
matrix[x][y]=i%2;
if(array[i]==-1)
j=1;
}
toggle = 0;
for(k=0;k<n;k++)
{
if(matrix[k][k] != parity)
toggle=1;
}
if(toggle==0)
return 0;
toggle=0;
for(k=0;k<n;k++)
{
if(matrix[k][n-k] != parity)
toggle=1;
}
if(toggle==0)
return 0;
if(j==1)
return 2;
return 1;
}