include stdafx include Windows define define int h8 int int int int in

 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
#include "stdafx.h"
#include <Windows.h>
#define N 7
#define M 8
int h8(int i,int j,int n, int s, int *p)
{
int a=0,b=0,c=0;
if (s<5)
{
if ((n==1 || n==0) && (j+1<M) && (*(p+i*M+j+1)==1))
a=h8(i,j+1,1,s+1,p);
if ( (n==2 || n==0) && (i+1<N) && (j+1<M) && (*(p+(i+1)*M+j+1)==1))
b=h8(i+1,j+1,2,s+1,p);
if ((n==3 || n==0) && (i+1<N) && (*(p+(i+1)*M+j)==1))
c=h8(i+1,j,3,s+1,p);
}
return max(a,max(b,c))+1;
}
int _tmain(int argc, _TCHAR* argv[])
{
int i,j,scet;
int mas[N][M]=
{
{1,1,1,1,0,0,0,1},
{1,1,0,0,0,0,1,0},
{1,1,1,1,0,0,0,1},
{1,0,0,1,0,0,0,1},
{0,0,0,0,1,0,0,1},
{1,0,0,1,0,1,1,0},
{0,0,0,0,1,0,1,0},
};
printf("\n ?????????? ???????:\n");
for(i=0;i<N;i++)
{
for(j=0;j<M;j++)
{
printf("%d \t ", mas[i][j]);
}
printf("\n");
}
int max=0;
for( i=0;i<N; i++)
{
for( j=0; j<M ; j++)
{
if(mas[i][j]==1)
{
scet=h8(i,j,0,0,*mas);
if (max<scet) max=scet;
}
else
scet=0;
printf("%d ",scet);
}
printf(" \n");
}
if(max>4)
printf( "yraaaa \n");
else
printf("no :( ");
system("PAUSE");
return 0;
}