const n=10; var a:array[1..n]of integer; i,o,s,z:integer; begin randomize;s:=0;z:=0;a[n]:=0; a[n]:=0;for i:=1 to n-1 do a[i]:=random(10)-5; for i:=1 to n do if (a[i]<0) and (z=0) then begin z:=1; for o:=i+1 to n do s:=s+a[o];end ;for i:=1 to n do write(a[i]:4);writeln; write('symma=',s);
Answers & Comments
Если на паскале
program dds;
const n=10;
var a:array[1..n]of integer;
i,o,s,z:integer;
begin randomize;s:=0;z:=0;a[n]:=0;
a[n]:=0;for i:=1 to n-1 do a[i]:=random(10)-5;
for i:=1 to n do if (a[i]<0) and (z=0)
then begin z:=1; for o:=i+1 to n do
s:=s+a[o];end
;for i:=1 to n do write(a[i]:4);writeln;
write('symma=',s);
readln;
end.