Var inputFile, positiveFile, negativeFile: Text; num: Integer;
Begin AssignFile(inputFile, 'des.dat'); Reset(inputFile); AssignFile(positiveFile, 'positiveNum.dat'); Rewrite(positiveFile); AssignFile(negativeFile, 'negativeNum.dat'); Rewrite(negativeFile);
While not eof(inputFile) do Begin Readln(inputFile, num); if num > 0 then Writeln(positiveFile, num) else if num < 0 then Writeln(negativeFile, num); End;
{$mode objfpc}
Program DivideNumbers;
Var
inputFile, positiveFile, negativeFile: Text;
num: Integer;
Begin
AssignFile(inputFile, 'des.dat');
Reset(inputFile);
AssignFile(positiveFile, 'positiveNum.dat');
Rewrite(positiveFile);
AssignFile(negativeFile, 'negativeNum.dat');
Rewrite(negativeFile);
While not eof(inputFile) do
Begin
Readln(inputFile, num);
if num > 0 then
Writeln(positiveFile, num)
else if num < 0 then
Writeln(negativeFile, num);
End;
CloseFile(inputFile);
CloseFile(positiveFile);
CloseFile(negativeFile);
End.