{$S-} program New; uses crt; label 1,2; type mass=array[1..100,1..100] of integer; line=array[1..100] of integer; var i,j,n:integer; matr,matrix:mass; procedure Readlines(var m:mass; n:integer); var i,j:integer; begin for i:=1 to n do for j:=1 to n do m[i,j]:=0; end; procedure Writelines(var m:mass; n:integer); var i,j:integer; begin for i:=1 to (n+1) do begin for j:=1 to (n+1) do if (i=1) and (j=1) then write(' ') else if j=1 then write((i-1):2,'*') else if i=1 then write((j-1):2) else write(m[i-1,j-1]:2); writeln end end; procedure recurse(var m:mass;i,j:integer); var k:integer; begin if (m[i, j] = 3) or (i>N) or (j>N) or (i<1) or (j<1) then exit; write('(',i,',',j,')',' '); if m[i,j]=2 then begin writeln('gotcha'); writelines(m,n); readln; exit end else begin m[i, j] := 3; recurse(m, i+2, j+1); recurse(m, i+2, j-1); recurse(m, i+1, j+2); recurse(m, i+1, j-2); recurse(m, i-2, j+1); recurse(m, i-2, j-1); recurse(m, i-1, j+2); recurse(m, i-1, j-2); end; end; procedure readpoint(var m:mass;point:integer); var i,j,a:integer; begin writeln('input entry point ', point,', use "xx" format:'); readln(a); i:=a div 10; j:=a mod 10; m[i,j]:=point; if point=1 then begin clrscr; recurse(matrix,i,j) end end; BEGIN 1: clrscr; writeln('please input n<=100'); readln(n); if (n>0) and (n<=100) then readlines(matrix,n) else goto 1; writelines(matrix,n); readpoint(matrix,2); readpoint(matrix,1); 2: writeln('Done!'); writelines(matrix,n); readln END .