Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
41
Task/Zig-zag-matrix/NetRexx/zig-zag-matrix.netrexx
Normal file
41
Task/Zig-zag-matrix/NetRexx/zig-zag-matrix.netrexx
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/* 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue