procedure insert( new : list; var pq : list );
label 9999;
var p : list;
begin
if pq=nil then pq := new
else if pq^.k < new^.k then begin
new^.next := pq;
pq := new
end
else begin
p := pq;
while p^.next <> nil do begin
if p^.next^.k < new^.k then begin
new^.next := p^.next;
p^.next := new;
goto 9999
end;
p := p^.next
end;
p^.next := new
end;
9999:
end;
|