Var ar:array[1..n] of integer; i,j,k:integer; begin k:=n; for i:=1 to n do readln(ar[i]); i:=1; while (i<>n) and (k<>0) do begin if ar[i]<0 then begin for j:=i to n-1 do ar[j]:=ar[j+1]; dec(k); end else inc(i); end; writeln('Final array:'); for i:=1 to k do write(ar[i]:4); end.
Answers & Comments
Verified answer
//Pascal ABC.NET v3.1 сборка 1219Const
n=5;
Var
ar:array[1..n] of integer;
i,j,k:integer;
begin
k:=n;
for i:=1 to n do
readln(ar[i]);
i:=1;
while (i<>n) and (k<>0) do
begin
if ar[i]<0 then
begin
for j:=i to n-1 do
ar[j]:=ar[j+1];
dec(k);
end
else inc(i);
end;
writeln('Final array:');
for i:=1 to k do
write(ar[i]:4);
end.