Magic squares of doubly even order: Difference between revisions

m
→‎{{header|REXX}}: added a comment, changed whitespace, used a template for the output section.
m (→‎{{header|REXX}}: added a comment, changed whitespace, used a template for the output section.)
Line 2,116:
<br>swapped &nbsp; (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; s= n%4; L= n%2-s+1; w= length(n**2) /*size; small sq; low middle; # width*/
@.= 0; H= n%2+s /*array default; high middle. */
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
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 /*cnegate*/
end /*rc*/
end /*r*/; return</lang>
'''{{out|output''' |text=&nbsp; when using the default input:}}
<pre>
1 2 62 61 60 59 7 8