Var a: array [1..10] of integer; pr, i, kol, sum: integer;begin sum := 0; pr := 1; for i := 1 to 10 do a[i] := -50 + random(100); for i := 1 to 10 do begin if (a[i] mod 2 = 1) or (a[i] mod 2 = -1) then // 1 sum := sum + a[i]; if (i mod 2 = 0) then // 2 pr := pr * a[i] else if (i mod 2 = 0) and (a[i] = 0) then pr := 0; end; for i := 1 to 10 do if (a[i] mod 10 = 0) then a[i] := 0; for i := 2 to 9 do // 3 begin if a[i] = 0 then if (a[i + 1] <> 0) and ((i + 1) mod 2 = 0) and (a[i - 1] <> 0) and ((i - 1) mod 2 = 0) then kol := kol + 1; end; writeln('сумму нечетных элементов =', ' ', sum); writeln('произведение элементов =', ' ', pr); writeln('число пар соседних элементов =', ' ', kol); end.
Var
x,y,v,h,dx:real;
Begin
Write('y = ');ReadLn(y);
Write('v = ');ReadLn(v);
Write('h = ');ReadLn(h);
dx:=0.31;
x:=-4;
Repeat
WriteLn('f(',x,') = ',Exp(Sin(y)*Abs(x))-3*Sqrt(v-h));
x:=x+dx;
Until x > -1
End.
Пример работы программы:
y = 3
v = 4
h = 2
f(-4) = -2.4841075227142
f(-3.69) = -2.55937994576573
f(-3.38) = -2.63143040076643
f(-3.07) = -2.70039680114727
f(-2.76) = -2.76641115707942
f(-2.45) = -2.82959982815798
f(-2.14) = -2.89008376526975
f(-1.83) = -2.94797874210812
f(-1.52) = -3.00339557677815
f(-1.21) = -3.05644034391605
a: array [1..10] of integer;
pr, i, kol, sum: integer;begin
sum := 0;
pr := 1;
for i := 1 to 10 do
a[i] := -50 + random(100);
for i := 1 to 10 do
begin
if (a[i] mod 2 = 1) or (a[i] mod 2 = -1) then // 1
sum := sum + a[i];
if (i mod 2 = 0) then // 2
pr := pr * a[i]
else if (i mod 2 = 0) and (a[i] = 0) then
pr := 0;
end;
for i := 1 to 10 do
if (a[i] mod 10 = 0) then
a[i] := 0;
for i := 2 to 9 do // 3
begin
if a[i] = 0 then
if (a[i + 1] <> 0) and ((i + 1) mod 2 = 0) and (a[i - 1] <> 0) and ((i - 1) mod 2 = 0) then
kol := kol + 1;
end;
writeln('сумму нечетных элементов =', ' ', sum);
writeln('произведение элементов =', ' ', pr);
writeln('число пар соседних элементов =', ' ', kol);
end.