Const n=10; var a:array[1..n] of integer; i,s1,s2:integer; begin Randomize; writeln('Массив A:'); for i:=1 to n do begin a[i]:=random(51)-25; write(a[i]:4); end; writeln; s1:=0; s2:=0; for i:=1 to n do if a[i]<0 then s1:=s1+a[i] else s2:=s2+a[i]; writeln('s1 = ',s1,' s2 = ',s2); if abs(s1)>s2 then writeln('Yes, |',s1,'| > ',s2) else writeln('No, |',s1,'| <= ',s2); end.
var a:array[1..n] of integer;
i,s1,s2:integer;
begin
Randomize;
writeln('Массив A:');
for i:=1 to n do
begin
a[i]:=random(51)-25;
write(a[i]:4);
end;
writeln;
s1:=0; s2:=0;
for i:=1 to n do
if a[i]<0 then s1:=s1+a[i] else s2:=s2+a[i];
writeln('s1 = ',s1,' s2 = ',s2);
if abs(s1)>s2
then writeln('Yes, |',s1,'| > ',s2)
else writeln('No, |',s1,'| <= ',s2);
end.
Пример:
Массив A:
-3 16 5 -14 -14 -4 -13 -25 13 16
s1 = -73 s2 = 50
Yes, |-73| > 50