unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Memo2: TMemo;
    Memo3: TMemo;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
 i: byte;
 m: integer;
 dir: string;
begin
if Memo1.Lines.Count = 0 then
 begin
  MessageBox(Handle, PAnsiChar('Не ведено ни одного числа'), PAnsiChar('ОШИБКА'), MB_ICONERROR);
  exit;
 end;
dir:= GetCurrentDir + '\';
for i:= 0 to Memo1.Lines.Count-1 do
 begin
  m:= strtoint(Memo1.Lines.Strings[i]);
  if m < 0 then Memo2.Lines.Add(inttostr(m))
  else Memo3.Lines.Add(inttostr(m));
 end;
Memo1.Lines.SaveToFile(dir + 'f1.txt');
Memo2.Lines.SaveToFile(dir + 'f2.txt');
Memo3.Lines.SaveToFile(dir + 'f3.txt');
MessageBox(Handle, PAnsiChar('Успешно выполнено'), PAnsiChar('Выполнено'), MB_ICONINFORMATION);
end;


end.
