NUMERIC DIGITS 10 vIM=139968 vIA=3877 vIC=29573 LAST=42 parse arg n If n < 1 Then Do n = 1 End Do i = 1 TO N ary.i = gen_random(1) End CALL heapsort N SAY ary.N EXIT gen_random: PROCEDURE EXPOSE LAST vIM vIA vIC PARSE ARG n LAST = (LAST * vIA + vIC) // vIM return n * LAST / vIM heapsort: PARSE ARG n rra = 0 i = 0 j = 0 l = (n % 2) + 1 ir = n Do While 1 If l > 1 Then Do l = l - 1 rra = ary.l End Else Do rra = ary.ir ary.ir = ary.1 ir = ir - 1 If ir = 1 Then Do ary.1 = rra return End End i = l j = l * 2 Do While j <= ir If j < ir Then Do jj = j+1 If ary.j < ary.jj Then Do j = j + 1 End End If rra < ary.j Then Do ary.i = ary.j i = j j = j + i End Else Do j = ir + 1 End End ary.i = rra End