program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;
var
A:array of array of Integer;
B:array of Integer;
i,j,N,M,t:Integer;
begin
{ TODO -oUser -cConsole Main : Insert code here }
t:=0;
while not (N in [1..100]) do
begin
write('N = ');
readln(N);
end;
while not (M in [1..100]) do
begin
write('M = ');
readln(M);
end;
SetLength(A,N,M);
Writeln('Matrix is - ');
for i:=0 to N-1 do
begin
for j:=0 to M-1 do
begin
A[i,j]:=Random(30)-10;
write(A[i,j],' ');
if A[i,j]>=0 then
begin
SetLength(B,t+1);
B[t]:=A[i,j];
Inc(t);
end;
end;
Writeln;
end;
Write('Massive B = ');
for i:=0 to t-1 do
write(B[i],' ');
A:=nil;
B:=nil;
readln;
end.