Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {Волкович Максим (volkovcih.maksim.s@gmail.com), 112гр., v1.0,
- описать процедуру, которая удаляет первый отрицательный элемент из списка L (если такой есть)}
- type list=^chain;
- chain=record elem:integer; next:list end;
- procedure dlt(var l:list);
- var b:boolean;
- t,p:list;
- begin
- b:=false; t:=l;
- if (l^.next=nil) and (l^.elem<0) then begin dispose(l); b:=true; end;
- if (l^.elem<0) and (l^.next<>nil) then begin b:=true; l:=t^.next; dispose(t); end;
- while (l^.elem>=0) and not(b) and (l^.next<>nil) do
- begin
- t:=l; l:=l^.next;
- end;
- if not b then
- begin if (l^.next=nil) and (l^.elem<0) then begin t^.next:=nil; p:=l; l:=t; dispose(p); end;
- if (l^.next<>nil) and (l^.elem<0) then begin p:=l; l:=l^.next; dispose(p); end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement