Skip to content

Instantly share code, notes, and snippets.

@augustoguerrero
Created December 16, 2016 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save augustoguerrero/ea30c35a900948e2e5b4b359c2d8d4bf to your computer and use it in GitHub Desktop.
Save augustoguerrero/ea30c35a900948e2e5b4b359c2d8d4bf to your computer and use it in GitHub Desktop.
Procedure InsertarOrdenado (var pri: lista; num:integer);
var
ant,nue,act:lista;
begin
new(nue);
nue^.elem := num;
nue^.sig := nil;
if (pri = nil) then
pri := nue;
else begin
act := pri;
ant := pri;
while (act <> NIL) and (act^.elem < nue^.elem) do begin
ant := act;
act := act^.sig;
end;
if (ant = act) then begin
nue^.sig:= pri;
pri := nue;
end
else begin
ant^.sig := nue;
nue^.sig := act;
end;
end;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment