program searcher; type PItem = ^TItem; TItem = record val:integer; next:PItem; end; var list,res:PItem; f:text; num:integer; procedure nacti(var f:text;var list:PItem); var pom:PItem; begin pom:=list; if not eof(f) then read(f,pom^.val); while not eof(f) do begin while not eoln(f) do begin new(pom^.next); pom:=pom^.next; read(f,pom^.val); pom^.next:=nil; end; readln(f); end; end; procedure vypis(list:PItem); var pom:PItem; begin pom:=list; while pom<>nil do begin write(pom^.val, ' '); pom:=pom^.next; end; writeln; end; function najdi(kde:PItem; co:integer):PItem; var pom:PItem; begin pom:=kde; while (pom <> nil) and (pom^.val<>co) do pom:=pom^.next; najdi:=pom; end; procedure odstran(list:PItem;co:PItem); var pom:integer; rem:PItem; begin if co <> nil then begin if co^.next = nil then begin rem:=list; while (rem^.next <> co) and (rem<> nil) do rem:=rem^.next; if(rem<>nil) then begin dispose(rem^.next); rem^.next:=nil; end end else begin rem:=co^.next; pom:=co^.val; co^.val:=co^.next^.val; co^.next^.val:=pom; co^.next:=co^.next^.next; dispose(rem); end; end; end; begin assign(f,'vstup.txt'); {$i-} reset(f); {$i+} if IOResult = 0 then begin new(list); nacti(f,list); vypis(list); write('Zadejte hledany prvek:'); readln(num); res:=najdi(list,num); if res <> nil then begin writeln('Prvek num je nalezen.'); odstran(list,res); vypis(list); end else writeln('Prvek num nebyl nalezen.'); end; end.