Program s1;vara:array [1..10] of integer; i,n,s,p,k1,k2:integer; begin write ('n-?'); readln(N); for i:=1 to n do Begin Write (i, '-й-?'); readln (a[i]); end; for i:=1 to n do write ('', a[i]); writeln; s:=0; p:=1; k1:=0; k2:=0; k3:=0; for i:=1 to n do begin{1} s:=s+a[i];{2} if a[i]>0 then p:=p*a[i];{3} if a[i]<0 then k1:=k1+1;{4} if a[i] mod 2=0 then k2:=k2+1;{5} if a[i] mod 2=1 then k3:=k3*i; end;writeln ('s=', s, ' p=', p, ' k1=', k1, ' k2=', k2, )end. Из этой задачи вывести произведение нечетных чисел в k3
Program s1; var a: array [1..10] of integer; i, n, s, p, k1, k2, k3: integer;
begin write ('n-?'); readln(N);
for i:=1 to n do Begin Write (i, '-й-?'); readln (a[i]); end;
for i:=1 to n do write ('', a[i]); writeln;
s:=0; p:=1; k1:=0; k2:=0; k3:=1; // Initialize k3 to 1 at the beginning
for i:=1 to n do begin s:=s+a[i]; // Sum of all elements
if a[i] > 0 then p:=p*a[i]; // Product of all positive elements if a[i] < 0 then k1:=k1+1; // Count of negative elements if a[i] mod 2 = 0 then k2:=k2+1; // Count of even elements if a[i] mod 2 = 1 then k3:=k3*a[i]; // Product of all odd elements
Program s1;
var
a: array [1..10] of integer;
i, n, s, p, k1, k2, k3: integer;
begin
write ('n-?');
readln(N);
for i:=1 to n do
Begin
Write (i, '-й-?');
readln (a[i]);
end;
for i:=1 to n do
write ('', a[i]);
writeln;
s:=0;
p:=1;
k1:=0;
k2:=0;
k3:=1; // Initialize k3 to 1 at the beginning
for i:=1 to n do
if a[i] > 0 thenbegin
s:=s+a[i]; // Sum of all elements
p:=p*a[i]; // Product of all positive elements
if a[i] < 0 then
k1:=k1+1; // Count of negative elements
if a[i] mod 2 = 0 then
k2:=k2+1; // Count of even elements
if a[i] mod 2 = 1 then
k3:=k3*a[i]; // Product of all odd elements
end;
writeln ('s=', s, ' p=', p, ' k1=', k1, ' k2=', k2, ' k3=', k3); // Output the results
end.