const n=10; var a: array [1..10] of Integer; i, k: Integer; begin Randomize; for i:=1 to n do a[i]:=-2+Random(5); Write('A ='); for i:=1 to n do Write(' ',a[i]); WriteLn; k:=0; for i:=1 to n do if a[i]<>0 then begin Inc(k); a[k]:=a[i]; end; Write('A''='); for i:=1 to k do Write(' ',a[i]); WriteLn; end.
Коды для удаление всех нолей:
const n=10; var a: array [1..10] of Integer; i, k: Integer; begin Randomize; for i:=1 to n do a[i]:=-2+Random(5); Write('A ='); for i:=1 to n do Write(' ',a[i]); WriteLn; k:=0; for i:=1 to n do if a[i]<>0 then begin Inc(k); a[k]:=a[i]; end; Write('A''='); for i:=1 to k do Write(' ',a[i]); WriteLn; end.