Сформировать целочисленный массив из n элементов. Значение элементов вводится с клавиатуры. Найти произведение элементов с черными номерами. Pascal

21 Окт 2019 в 09:44
187 +1
0
Ответы
1

program ProductOfElements;

var
n, i: integer;
arr: array of integer;
product: integer;

begin
writeln('Enter the number of elements in the array: ');
readln(n);

SetLength(arr, n);

writeln('Enter the elements of the array:');
for i := 0 to n - 1 do
begin
readln(arr[i]);
end;

product := 1;
for i := 0 to n - 1 do
begin
if (i mod 2 = 0) then // Check if the index is even (black number)
begin
product := product * arr[i];
end;
end;

writeln('The product of elements with black indices is: ', product);

end.

19 Апр 2024 в 10:05
Не можешь разобраться в этой теме?
Обратись за помощью к экспертам
Гарантированные бесплатные доработки в течение 1 года
Быстрое выполнение от 2 часов
Проверка работы на плагиат
Поможем написать учебную работу
Прямой эфир