Sattolo cycle: Difference between revisions
→{{header|ALGOL 68}}: Spelling :(
(Added Algol 68) |
(→{{header|ALGOL 68}}: Spelling :() |
||
Line 74:
Arrays in Algol 68 need not have a lower bound of 0, other than that, this implements the pseudo code.
<lang algol68>BEGIN
# reorders the elements of a using the
# this operates on integer arrays, additional
# could be defined for other types #
# a is returned so we can write e.g.
# the elements twice #
OP
BEGIN
REF[]INT aa := a[ @ 0 ];
Line 89:
OD;
a
END #
[ 1 : 10 ]INT a := []INT( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 )[ @ 1 ];
TO 5 DO
FOR i FROM LWB a TO UPB a DO print( ( " ", whole( a[ i ], -3 ) ) ) OD;
print( ( newline ) )
OD
END
</lang>
{{out}}
<pre>
|