Magic squares of doubly even order: Difference between revisions
Content deleted Content added
m →{{header|REXX}}: added a comment, changed whitespace, used a template for the output section. |
|||
Line 2,116:
<br>swapped (and thusly, stay in place in the magic square).
<lang rexx>/*REXX program constructs a magic square of doubly even sides (a size divisible by 4).*/
n= 8;
@.= 0;
call gen /*generate a grid in numerical order. */
call diag /*mark numbers on both diagonals. */
Line 2,139:
do c=1 for n; if @.r.c<0 then iterate; call max# /*find max number.*/
parse value -@.a.b (-@.r.c) with @.r.c @.a.b /*swap two values.*/
end /*c*/
end /*r*/; return
/*──────────────────────────────────────────────────────────────────────────────────────*/
corn: do r=1 for n; if r>s & r<=n-s then iterate /*"corner boxen", size≡S*/
do c=1 for n; if c>s & c<=n-s then iterate; @.r.c= -@(r,c)
end /*
end /*r*/; return</lang>
<pre>
1 2 62 61 60 59 7 8
|