Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
27
Task/Floyds-triangle/NetRexx/floyds-triangle-1.netrexx
Normal file
27
Task/Floyds-triangle/NetRexx/floyds-triangle-1.netrexx
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref symbols binary
|
||||
/* REXX ***************************************************************
|
||||
* 12.07.2012 Walter Pachl - translated from Python
|
||||
**********************************************************************/
|
||||
Parse Arg rowcount .
|
||||
if rowcount.length() == 0 then rowcount = 1
|
||||
say 'Rows:' rowcount
|
||||
say
|
||||
col = 0
|
||||
len = Rexx ''
|
||||
ll = '' -- last line of triangle
|
||||
Loop j = rowcount * (rowcount - 1) / 2 + 1 to rowcount * (rowcount + 1) / 2
|
||||
col = col + 1 -- column number
|
||||
ll = ll j -- build last line
|
||||
len[col] = j.length() -- remember length of column
|
||||
End j
|
||||
Loop i = 1 To rowcount - 1 -- now do and output the rest
|
||||
ol = ''
|
||||
col = 0
|
||||
Loop j = i * (i - 1) / 2 + 1 to i * (i + 1) / 2 -- elements of line i
|
||||
col = col + 1
|
||||
ol=ol j.right(len[col]) -- element in proper length
|
||||
end
|
||||
Say ol -- output ith line
|
||||
end i
|
||||
Say ll -- output last line
|
||||
19
Task/Floyds-triangle/NetRexx/floyds-triangle-2.netrexx
Normal file
19
Task/Floyds-triangle/NetRexx/floyds-triangle-2.netrexx
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref symbols binary
|
||||
/*REXX program constructs & displays Floyd's triangle for any number of rows.*/
|
||||
parse arg numRows .
|
||||
if numRows == '' then numRows = 1 -- assume 1 row if not given
|
||||
maxVal = numRows * (numRows + 1) % 2 -- calculate the max value.
|
||||
say 'displaying a' numRows "row Floyd's triangle:"
|
||||
say
|
||||
digit = 1
|
||||
loop row = 1 for numRows
|
||||
col = 0
|
||||
output = ''
|
||||
loop digit = digit for row
|
||||
col = col + 1
|
||||
colMaxDigit = maxVal - numRows + col
|
||||
output = output Rexx(digit).right(colMaxDigit.length())
|
||||
end digit
|
||||
say output
|
||||
end row
|
||||
Loading…
Add table
Add a link
Reference in a new issue