unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    Memo1: TMemo;
    Label1: TLabel;
    Memo2: TMemo;
    Label2: TLabel;
    Button2: TButton;
    Label3: TLabel;
    Label4: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
type  spisok=^zveno;
      zveno=record
                el:string;
                sled:spisok;
            end;
var
L:spisok;
tec, tec1, tec1_el:spisok;
e,e1:string;
i:integer;
f:boolean;
procedure sp(E1,E:spisok; var L:spisok);
  begin
  ;
  end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  L:=nil;
  for i:=1 to memo1.Lines.count do
  begin
    new(tec);
    tec^.el:=memo1.Lines[i-1];
    tec^.sled:=L;
    L:=tec;
  end;
  memo1.Clear;
  tec:=L;
  while tec<>nil do
    begin
      memo1.Lines.Add(tec^.el);
      tec:=tec^.sled;
    end;

end;

procedure TForm1.Button2Click(Sender: TObject);

begin
  tec1:=L;
  e:=Edit2.Text;
  e1:=Edit1.Text;
  f:=true;
  while (tec1<> nil) and f do
    begin
    if tec1^.el=e
    then
      begin
      f:=false;
      new(tec1_el);
      tec1_el^.el:=e1;
      tec1_el:=tec^.sled;
      tec^.sled:=tec1_el;
      end
    else
      begin
      tec1:=tec1^.sled;
      tec:=tec^.sled;
      end;
    //  Memo2.Lines.Add(tec^.el);
    end;
{if f then}  while tec<>nil do begin
 Memo2.Lines.Add(tec^.el);
 tec:=tec^.sled; end;
end;

end.
