REM Ход конем
DECLARE SUB NEWLEVEL ()
DECLARE SUB TRY (P!, Q!)
DIM SHARED A(8, 8), K, XOD
FOR I = 0 TO 7: FOR J = 0 TO 7
A(I, J) = -1
NEXT J: NEXT I
CLS : INPUT "Задайте начальную позицию :", I, J
A(I, J) = 0: K = 0
M: NEWLEVEL: IF XOD = 1 THEN GOTO M
FOR I = 0 TO 7: FOR J = 0 TO 7
PRINT A(I, J);
NEXT J: PRINT : NEXT I
END
SUB NEWLEVEL
XOD = 0
FOR I = 0 TO 7: FOR J = 0 TO 7
IF A(I, J) = K THEN
TRY I - 2, J - 1: TRY I - 2, J + 1
TRY I - 1, J - 2: TRY I - 1, J + 2
TRY I + 1, J - 2: TRY I + 1, J + 2
TRY I + 2, J - 1: TRY I + 2, J + 1
END IF
NEXT J: NEXT I
K = K + 1
END SUB
SUB TRY (P, Q)
IF P >= 0 AND P < 8 AND Q >= 0 AND Q < 8 THEN
IF A(P, Q) < 0 THEN A(P, Q) = K + 1: XOD = 1
END IF
END SUB