2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -1,22 +1,22 @@
/*REXX program loops through a 2-dimensional array to look for a '20'. */
parse arg rows cols targ . /*obtain optional args from C.L. */
if rows=='' | rows==',' then rows=60 /*Rows not specified? Use default*/
if cols=='' | cols==',' then cols=10 /*Cols " " " " */
if targ=='' | targ==',' then targ=20 /*Targ " " " " */
w=max(length(rows),length(cols),length(targ)) /*for formatting output.*/
not='not' /* [↓] construct the 2-dim array.*/
do row=1 for rows /*1st dimension of the array. */
do col=1 for cols /*2nd " " " " */
@.row.col=random(1,targ) /*generate some random numbers. */
/*REXX program loops through a two-dimensional array to search for a '20' (twenty). */
parse arg rows cols targ . /*obtain optional arguments from the CL*/
if rows=='' | rows=="," then rows=60 /*Rows not specified? Then use default*/
if cols=='' | cols=="," then cols=10 /*Cols " " " " " */
if targ=='' | targ=="," then targ=20 /*Targ " " " " " */
w=max(length(rows), length(cols), length(targ)) /*W: used for formatting the output. */
not= 'not' /* [↓] construct the 2─dimension array*/
do row=1 for rows /*ROW is the 1st dimension of array. */
do col=1 for cols /*COL " " 2nd " " " */
@.row.col=random(1, targ) /*create some positive random integers.*/
end /*row*/
end /*col*/
/*═════════════════════════════════════now, search for the target {20}.*/
do r=1 for rows
do r=1 for rows /* ◄───────────────── now, search for the target {20}.*/
do c=1 for cols
say left('@.'r"."c,3+w+w) '=' right(@.r.c,w) /*display.*/
if @.r.c==targ then do; not=; leave r; end /*found ? */
say left('@.'r"."c, 3+w+w) '=' right(@.r.c, w) /*show an array element.*/
if @.r.c==targ then do; not=; leave r; end /*found the targ number?*/
end /*c*/
end /*r*/
say right(space('Target' not 'found:') targ, 33, '')
/*stick a fork in it, we're done.*/
say right( space( 'Target' not "found:" ) targ, 33, '')
/*stick a fork in it, we're all done. */