Anonymous user
Sort three variables: Difference between revisions
m
→{{header|REXX}}: undid someone's older change, added/changed whitespace.
No edit summary |
m (→{{header|REXX}}: undid someone's older change, added/changed whitespace.) |
||
Line 2,055:
say '───── original value of Y: ' y
say '───── original value of Z: ' z
if x>y then do; _= x; x= y; y= _;
if y>z then do; _= y; y= z; z= _;
if x>y then do; _= x; x= y; y= _;
say /*stick a fork in it, we're all done. */
say '═════ sorted value of X: ' x
Line 2,063:
say '═════ sorted value of Z: ' z</lang>
{{out|output|text=when using the default inputs:}}
<pre>
───── original value of Y: bears, oh my!
───── original value of Z: (from "The Wizard of Oz")
Line 2,069 ⟶ 2,070:
═════ sorted value of X: (from "The Wizard of Oz")
═════ sorted value of Y: bears, oh my!
═════ sorted value of Z: lions, tigers, and
</pre>
===numeric only===
Line 2,081 ⟶ 2,083:
if y=='' | y=="," then y= -12 /* " " " " " " */
if z=='' | z=="," then z= 0 /* " " " " " " */
w= max( length(x), length(y), length(z) ) + 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)
z= max(low, mid, high)
y= low + mid + high - x - z
/*stick a fork in it, we're all done. */
say '═════ sorted values of X, Y, and Z: '
{{out|output|text= when using the default inputs:}}
<pre>
<pre>───── original values of X, Y, and Z: 77444 -12 0▼
</pre>
=={{header|Ring}}==
|