unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Edit1: TEdit;
    Label2: TLabel;
    Edit2: TEdit;
    procedure FormCreate(Sender: TObject);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
Function Sr(S1:string):string;
var n:integer; S2,p:string; k:char;
begin
s1:=s1+' ';
  while length(S1)>0 do
    begin
      n:=Pos(' ',S1);
      S2:=Copy(S1,1,n-1);
      k:=S2[length(S2)];

        if k in ['0','2','4','6','8'] then
        p:=p+' '+S2;
      delete(S1,1,n);
    end;
    result:=p;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
edit1.Clear;
edit2.Clear;
end;

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then Edit2.Text:=Sr(Edit1.Text);
end;

end.
