Var X:array[1..100] of integer; i,k:integer; S:real; Begin S:=0; Write('k = ');ReadLn(k); Write('Введите массив X[',k,']: '); For k:= 1 to k do Read(X[k]); i:=1; if X[1]<0 then Begin While (i<=k)and(X[i]<0) do Begin S:=S+X[i]; i:=i+1; End; End else Begin While (i<=k)and(X[i]>=0) do Begin S:=S+X[i]; i:=i+1; End; End; WriteLn('S = ',S); End.
X:array[1..100] of integer;
i,k:integer;
S:real;
Begin
S:=0;
Write('k = ');ReadLn(k);
Write('Введите массив X[',k,']: ');
For k:= 1 to k do
Read(X[k]);
i:=1;
if X[1]<0 then
Begin
While (i<=k)and(X[i]<0) do
Begin
S:=S+X[i];
i:=i+1;
End;
End
else
Begin
While (i<=k)and(X[i]>=0) do
Begin
S:=S+X[i];
i:=i+1;
End;
End;
WriteLn('S = ',S);
End.