var
a, b: array[1..15] of integer;
i, k: integer;
begin
randomize;
k := 1;
WriteLn('Массив:');
for i := 1 to 15 do
a[i] := random(200) - 100;
Write(a[i], ', ');
if a[i] < 0 then
b[k] := a[i];
inc(k);
end;
WriteLn;
WriteLn('Новый массив:');
for i := 1 to k - 1 do Write(b[i], ', ');
end.
Объяснение:
var
a, b: array[1..15] of integer;
i, k: integer;
begin
randomize;
k := 1;
WriteLn('Массив:');
for i := 1 to 15 do
begin
a[i] := random(200) - 100;
Write(a[i], ', ');
if a[i] < 0 then
begin
b[k] := a[i];
inc(k);
end;
end;
WriteLn;
WriteLn('Новый массив:');
for i := 1 to k - 1 do Write(b[i], ', ');
end.
Объяснение: