Const n=15; var i,np,nn,amax:integer; a:array[1..n] of integer; begin Randomize; Write('Исходный массив: '); np:=0; nn:=0; for i:=1 to n do begin a[i]:=Random(51)-15; Write(a[i],' '); if a[i]>0 then Inc(np) else if a[i]<0 then Inc(nn); end; Writeln; if np/nn>2 then begin amax:=a[i]; for i:=2 to n do if a[i]>amax then amax:=a[i]; Write('Выходной массив: '); for i:=1 to n do begin if a[i]<0 then a[i]:=1 else if a[i]>0 then a[i]:=a[i]*amax; Write(a[i],' ') end; Writeln end else Writeln('В массив изменения не вносятся') end.
var a,k,s: integer; begin read(a); k := 0; s := 0; while a mod 2 <> 0 do begin if abs(a) mod 10 > 5 then s := s + a; a := abs(a); if (a > 9) and (a < 100) then k := k + 1; read(a); end; writeln('k=',k,', s=',s) end.
{2}
var n,i,p,a: integer; begin read(n); p := 1; for i := 1 to n do begin read(a); if (a > 0) and (a mod 3 = 0) then p := p * a; end; writeln('p=',p) end.
{3}
var n,a,i,k,s: integer; begin read(n); k := 0; s := 0; for i := 1 to n do begin read(a); if a > 0 then begin s := s + a; k := k + 1; end; end; if k = 0 then k := 1; writeln('s=',s/k) end.
n=15;
var
i,np,nn,amax:integer;
a:array[1..n] of integer;
begin
Randomize;
Write('Исходный массив: ');
np:=0; nn:=0;
for i:=1 to n do begin
a[i]:=Random(51)-15;
Write(a[i],' ');
if a[i]>0 then Inc(np)
else if a[i]<0 then Inc(nn);
end;
Writeln;
if np/nn>2 then begin
amax:=a[i];
for i:=2 to n do
if a[i]>amax then amax:=a[i];
Write('Выходной массив: ');
for i:=1 to n do begin
if a[i]<0 then a[i]:=1
else
if a[i]>0 then a[i]:=a[i]*amax;
Write(a[i],' ')
end;
Writeln
end
else Writeln('В массив изменения не вносятся')
end.
Пример работы программы
Исходный массив: 28 8 21 32 0 26 30 11 35 21 14 6 0 -4 -8
Выходной массив: 980 280 735 1120 0 910 1050 385 1225 735 490 210 0 1 1
var
a,k,s: integer;
begin
read(a);
k := 0; s := 0;
while a mod 2 <> 0 do
begin
if abs(a) mod 10 > 5 then
s := s + a;
a := abs(a);
if (a > 9) and (a < 100) then
k := k + 1;
read(a);
end;
writeln('k=',k,', s=',s)
end.
{2}
var
n,i,p,a: integer;
begin
read(n);
p := 1;
for i := 1 to n do
begin
read(a);
if (a > 0) and (a mod 3 = 0) then
p := p * a;
end;
writeln('p=',p)
end.
{3}
var
n,a,i,k,s: integer;
begin
read(n);
k := 0; s := 0;
for i := 1 to n do
begin
read(a);
if a > 0 then
begin
s := s + a;
k := k + 1;
end;
end;
if k = 0 then k := 1;
writeln('s=',s/k)
end.