RosettaCodeData/Task/Sort-three-variables/XPL0/sort-three-variables.xpl0

32 lines
738 B
Plaintext

include xpllib; \for StrSort and Print
int X, Y, Z;
int L, M, H;
real RX, RY, RZ, RT;
[X:= 77444; Y:= -12; Z:= 0;
L:= X;
if L>Y then L:= Y;
if L>Z then L:= Z;
H:= X;
if H<Y then H:= Y;
if H<Z then H:= Z;
M:= X+Y+Z-L-H;
IntOut(0, L); CrLf(0);
IntOut(0, M); CrLf(0);
IntOut(0, H); CrLf(0);
RX:= 11.3; RY:= -9.7; RZ:= 11.17;
if RX>RY then [RT:= RX; RX:= RY; RY:= RT];
if RY>RZ then [RT:= RY; RY:= RZ; RZ:= RT];
if RX>RY then [RT:= RX; RX:= RY; RY:= RT];
RlOut(0, RX); CrLf(0);
RlOut(0, RY); CrLf(0);
RlOut(0, RZ); CrLf(0);
X:= "lions, tigers, and";
Y:= "bears, oh my!";
Z:= "(from the ^"Wizard of OZ^")";
StrSort(@X, 3); \the address of X is used as an array containing X, Y, Z
Print("%s\n%s\n%s\n", X, Y, Z);
]