Äàí îäíîìåðíûé ìàññèâ. Âñå åãî ýëåìåíòû, íå ðàâíûå íóëþ, ïåðåïèñàòü, ñîõðàíÿÿ èõ ïîðÿäîê â íà÷àëî ìàññèâà, à íóëåâûå ýëåìåíòû â êîíåö ìàññèâà. Íîâûé ìàññèâ íå çàâîäèòü.
Uses CRT;
Const N = 20;
FindElem = 0;
Var A:Array[1..N] Of Integer;
I,J,M : Integer;
Procedure
DeleteElem (S:Integer);
Var J : Integer;
Begin
For J := S To N-1
Do
Begin
A[J] :=
A[J+1];
End;
End;
BEGIN
ClrScr;
Randomize;
For I := 1 To N
Do A[I] := Random(5);
WriteLn('All
elements of array A:');
For I := 1 To N
Do Write(A[I]:3);
WriteLn;
I := 1;
M := N;
While I<=M Do
Begin
If A[I] =
FindElem Then
Begin
DeleteElem(I);
A[M]
:= FindElem;
Dec(M);
End
Else
Inc(I);
End;
For I := 1 To N
Do Write(A[I]:3);
END.