Last list item: Difference between revisions
ALGOL 68 →With sorting: Use new ALGOL 68-rows library
(add BQN) |
(ALGOL 68 →With sorting: Use new ALGOL 68-rows library) |
||
Line 12:
===With sorting===
{{trans|Wren}}
{{libheader|ALGOL 68-rows}}
<lang algol68>BEGIN # find the last element after repeatedely adding the sum #
# of the two smallest elements and removing them #
PR read "rows.incl.a68" PR # row related utilities #
[ 1 : 9 ]INT a := ( 6, 81, 243, 14, 25, 49, 123, 69, 11 );
INT a count := UPB a;
WHILE a count > 1 DO
print( ( "Sorted list:" ) );FOR i TO a count DO print( ( " ", whole( a[ i ], 0 ) ) ) OD;
INT sum = a[ 1 ] + a[ 2 ];
|