|
魔方陣(4*N 魔方陣)
OPTION BASE 0
DIM A(27, 27)
FOR L=4 TO 24 STEP 4
FOR M = 0 TO L / 4
FOR N = 0 TO L / 4
LET A(4 * N, 4 * M) = 1
LET A(4 * N + 1, 4 * M) = 1
LET A(4 * N + 1, 4 * M + 1) = 1
LET A(4 * N, 4 * M + 1) = 1
LET A(4 * N + 2, 4 * M + 2) = 1
LET A(4 * N + 3, 4 * M + 2) = 1
LET A(4 * N + 2, 4 * M + 3) = 1
LET A(4 * N + 3, 4 * M + 3) = 1
NEXT N
NEXT M
FOR Y = 1 TO L
FOR X = 1 TO L
IF A(X, Y) = 1 THEN LET A(X, Y) = L * (Y - 1) + X ELSE LET A(X, Y) = L * L - (L * (Y - 1) + X - 1)
NEXT X
NEXT Y
PRINT L; " * "; L; " 魔方陣"
FOR Y = 1 TO L
FOR X = 1 TO L
PRINT USING "#####": A(X,Y);
NEXT X
PRINT
NEXT Y
PRINT
MAT A=ZER
NEXT L
END
|
|