//1) var A: array [1..20] of real; D: real; i, z: byte; begin write('Введите D: '); readln(D); writeln('Исходный массив.'); for i := 1 to 20 do begin readln(A[i]); if A[i] = D then z := z + 1; end; writeln; writeln('Чисел равных D = ', z); end.
//2) var A: array [1..20] of integer; i: byte; z: longint; //biginteger, extended begin randomize; z := 1; for i := 1 to 20 do begin A[i] := random(49)+1; if A[i] mod 2 <> 0 then z := z * A[i]; write(A[i], ' '); end; writeln; writeln('Произведение нечетных элементов = ', z); end.
Answers & Comments
Verified answer
//1)var
A: array [1..20] of real;
D: real;
i, z: byte;
begin
write('Введите D: '); readln(D);
writeln('Исходный массив.');
for i := 1 to 20 do
begin
readln(A[i]);
if A[i] = D then z := z + 1;
end;
writeln;
writeln('Чисел равных D = ', z);
end.
//2)
var
A: array [1..20] of integer;
i: byte;
z: longint; //biginteger, extended
begin
randomize;
z := 1;
for i := 1 to 20 do
begin
A[i] := random(49)+1;
if A[i] mod 2 <> 0 then z := z * A[i];
write(A[i], ' ');
end;
writeln;
writeln('Произведение нечетных элементов = ', z);
end.