|
OPTION BASE 0
LET K=24
DIM A(K+3,K+3)
FOR L=4 TO K 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
4 × 4 魔方陣
1 15 14 4
12 6 7 9
8 10 11 5
13 3 2 16
8 × 8 魔方陣
1 63 62 4 5 59 58 8
56 10 11 53 52 14 15 49
48 18 19 45 44 22 23 41
25 39 38 28 29 35 34 32
33 31 30 36 37 27 26 40
24 42 43 21 20 46 47 17
16 50 51 13 12 54 55 9
57 7 6 60 61 3 2 64
OPTION BASE 0
LET M=30
DIM A(M,M)
FOR N=6 TO M STEP 4
!'N=NN*4+2
LET K=N*2-2
FOR I=1 TO N-2
FOR J=1 TO N-2
IF BITAND(I,2)=BITAND(J,2) THEN
LET K=K+1
LET A(I,J)=K
ELSE
LET K=K+1
LET A(N-1-I,N-1-J)=K
END IF
NEXT J
NEXT I
LET SUM=N*N+1
LET A(0,0)=N-2
LET A(N-1,N-1)=SUM-(N-2)
LET A(0,N-1)=N-1
LET A(N-1,0)=SUM-(N-1)
LET A(0,N-2)=SUM-2*N+3
LET A(N-1,N-2)=SUM-(SUM-2*N+3)
LET A(N-2,0)=2*N-2
LET A(N-2,N-1)=SUM-(2*N-2)
FOR I=1 TO N-3
IF BITAND(I,2)=0 THEN LET J=0 ELSE LET J=N-1
LET A(J,I)=N-2-I
LET A(N-1-J,I)=SUM-(N-2-I)
LET A(I,J)=N-1+I
LET A(I,N-1-J)=SUM-(N-1+I)
NEXT I
PRINT N;"*";N;"魔方陣"
FOR I=0 TO N-1
FOR J=0 TO N-1
PRINT USING" #####":A(I,J);
NEXT J
PRINT
NEXT I
PRINT
NEXT N
END
6 * 6 魔方陣
4 3 35 36 28 5
6 11 25 24 14 31
30 22 16 17 19 7
29 18 20 21 15 8
10 23 13 12 26 27
32 34 2 1 9 33
10 * 10 魔方陣
8 7 95 96 4 3 99 100 84 9
10 19 81 80 22 23 77 76 26 91
90 74 28 29 71 70 32 33 67 11
89 66 36 37 63 62 40 41 59 12
13 43 57 56 46 47 53 52 50 88
14 51 49 48 54 55 45 44 58 87
86 42 60 61 39 38 64 65 35 15
85 34 68 69 31 30 72 73 27 16
18 75 25 24 78 79 21 20 82 83
92 94 6 5 97 98 2 1 17 93
|
|