Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
15
Task/Sort-three-variables/REXX/sort-three-variables-1.rexx
Normal file
15
Task/Sort-three-variables/REXX/sort-three-variables-1.rexx
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/*REXX program sorts three (any value) variables (X, Y, and Z) into ascending order.*/
|
||||
parse arg x y z . /*obtain the three variables from C.L. */
|
||||
if x=='' | x=="," then x= 'lions, tigers, and' /*Not specified? Use the default*/
|
||||
if y=='' | y=="," then y= 'bears, oh my!' /* " " " " " */
|
||||
if z=='' | z=="," then z= '(from "The Wizard of Oz")' /* " " " " " */
|
||||
say '───── original value of X: ' x
|
||||
say '───── original value of Y: ' y
|
||||
say '───── original value of Z: ' z
|
||||
if x>y then do; _= x; x= y; y= _; end /*swap the values of X and Y. */ /* ◄─── sorting.*/
|
||||
if y>z then do; _= y; y= z; z= _; end /* " " " " Y " Z. */ /* ◄─── sorting.*/
|
||||
if x>y then do; _= x; x= y; y= _; end /* " " " " X " Y. */ /* ◄─── sorting */
|
||||
say /*stick a fork in it, we're all done. */
|
||||
say '═════ sorted value of X: ' x
|
||||
say '═════ sorted value of Y: ' y
|
||||
say '═════ sorted value of Z: ' z
|
||||
16
Task/Sort-three-variables/REXX/sort-three-variables-2.rexx
Normal file
16
Task/Sort-three-variables/REXX/sort-three-variables-2.rexx
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/*REXX program sorts three (numeric) variables (X, Y, and Z) into ascending order. */
|
||||
numeric digits 1000 /*handle some pretty gihugic integers. */ /*can be bigger.*/
|
||||
parse arg x y z . /*obtain the three variables from C.L. */
|
||||
if x=='' | x=="," then x= 77444 /*Not specified? Then use the default.*/
|
||||
if y=='' | y=="," then y= -12 /* " " " " " " */
|
||||
if z=='' | z=="," then z= 0 /* " " " " " " */
|
||||
w= max( length(x), length(y), length(z) ) + 5 /*find max width of the values, plus 5.*/
|
||||
say '───── original values of X, Y, and Z: ' right(x, w) right(y, w) right(z, w)
|
||||
low = x /*assign a temporary variable. */
|
||||
mid = y /* " " " " */
|
||||
high= z /* " " " " */
|
||||
x= min(low, mid, high) /*determine the lowest value of X,Y,Z. */ /* ◄─── sorting.*/
|
||||
z= max(low, mid, high) /* " " highest " " " " " */ /* ◄─── sorting.*/
|
||||
y= low + mid + high - x - z /* " " middle " " " " " */ /* ◄─── sorting.*/
|
||||
/*stick a fork in it, we're all done. */
|
||||
say '═════ sorted values of X, Y, and Z: ' right(x, w) right(y, w) right(z, w)
|
||||
Loading…
Add table
Add a link
Reference in a new issue