def even_numbers(arr): even_nums = [num for num in arr if num % 2 == 0] k = len(even_nums) for i in range(len(arr)): if arr[i] in even_nums: print(f"Index: {i}, Number: {arr[i]}") print(f"Total even numbers: {k}") # Пример использования arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] even_numbers(arr)
Пример кода на Python:
def even_numbers(arr):even_nums = [num for num in arr if num % 2 == 0]
k = len(even_nums)
for i in range(len(arr)):
if arr[i] in even_nums:
print(f"Index: {i}, Number: {arr[i]}")
print(f"Total even numbers: {k}")
# Пример использования
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
even_numbers(arr)
Результат выполнения кода:
Index: 1, Number: 2Index: 3, Number: 4
Index: 5, Number: 6
Index: 7, Number: 8
Index: 9, Number: 10
Total even numbers: 5