Var a: array[1..10] of integer; i, sum, max: integer; begin randomize; for i:=1 to 10 do a[i] := random(46) - 11; sum := 0; max := -12; for i:=1 to 10 do begin if (a[i] mod 2 > 0) and (a[i] > 0) then inc(sum, a[i]); if (a[i] > max) and (a[i] < 0) then max := a[i]; end; writeln(sum); if max <> -12 then writeln(max) else writeln('Такого элемента нет'); end.
Answers & Comments
Verified answer
Vara: array[1..10] of integer;
i, sum, max: integer;
begin
randomize;
for i:=1 to 10 do
a[i] := random(46) - 11;
sum := 0; max := -12;
for i:=1 to 10 do
begin
if (a[i] mod 2 > 0) and (a[i] > 0) then
inc(sum, a[i]);
if (a[i] > max) and (a[i] < 0) then
max := a[i];
end;
writeln(sum);
if max <> -12 then
writeln(max)
else
writeln('Такого элемента нет');
end.