Data update
This commit is contained in:
parent
72eb4943cb
commit
4d5544505c
2347 changed files with 62432 additions and 16731 deletions
14
Task/Sort-three-variables/Crystal/sort-three-variables.cr
Normal file
14
Task/Sort-three-variables/Crystal/sort-three-variables.cr
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
x = "lions, tigers, and"
|
||||
y = "bears, oh my!"
|
||||
z = "(from the \"Wizard of OZ\")"
|
||||
|
||||
x, y, z = [x, y, z].sort
|
||||
puts "x = #{x}", "y = #{y}", "z = #{z}"
|
||||
puts "--"
|
||||
|
||||
x = 77444
|
||||
y = -12
|
||||
z = 0
|
||||
|
||||
x, y, z = [x, y, z].sort
|
||||
puts "x = #{x}", "y = #{y}", "z = #{z}"
|
||||
|
|
@ -1,13 +1,7 @@
|
|||
proc sort3 . a b c .
|
||||
if a > c
|
||||
swap a c
|
||||
.
|
||||
if b > c
|
||||
swap b c
|
||||
.
|
||||
if a > b
|
||||
swap a b
|
||||
.
|
||||
proc sort3 &a &b &c .
|
||||
if a > c : swap a c
|
||||
if b > c : swap b c
|
||||
if a > b : swap a b
|
||||
.
|
||||
x = 77444
|
||||
y = -12
|
||||
|
|
@ -15,16 +9,10 @@ z = 0
|
|||
sort3 x y z
|
||||
print x & " " & y & " " & z
|
||||
#
|
||||
proc sort3str . a$ b$ c$ .
|
||||
if strcmp a$ c$ > 0
|
||||
swap a$ c$
|
||||
.
|
||||
if strcmp b$ c$ > 0
|
||||
swap b$ c$
|
||||
.
|
||||
if strcmp a$ b$ > 0
|
||||
swap a$ b$
|
||||
.
|
||||
proc sort3str &a$ &b$ &c$ .
|
||||
if strcmp a$ c$ > 0 : swap a$ c$
|
||||
if strcmp b$ c$ > 0 : swap b$ c$
|
||||
if strcmp a$ b$ > 0 : swap a$ b$
|
||||
.
|
||||
x$ = "lions, tigers, and"
|
||||
y$ = "bears, oh my!"
|
||||
|
|
|
|||
31
Task/Sort-three-variables/XPL0/sort-three-variables.xpl0
Normal file
31
Task/Sort-three-variables/XPL0/sort-three-variables.xpl0
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
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);
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue