Created
December 16, 2016 18:09
-
-
Save augustoguerrero/ea30c35a900948e2e5b4b359c2d8d4bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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