RosettaCodeData/Task/Zig-zag-matrix/NetRexx/zig-zag-matrix.netrexx
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

41 lines
865 B
Text

/* NetRexx */
options replace format comments java crossref savelog symbols binary
zigzag(5)
return
method zigzag(msize) public static
row = 1
col = 1
ziggy = Rexx(0)
loop j_ = 0 for msize * msize
ziggy[row, col] = j_
if (row + col) // 2 == 0 then do
if col < msize then -
col = col + 1
else row = row + 2
if row \== 1 then -
row = row - 1
end
else do
if row < msize then -
row = row + 1
else col = col + 2
if col \== 1 then -
col = col - 1
end
end j_
L = (msize * msize - 1).length /*for a constant element width. */
loop row = 1 for msize /*show all the matrix's rows. */
rowOut = ''
loop col = 1 for msize
rowOut = rowOut ziggy[row, col].right(L)
end col
say rowOut
end row
return