Создать программу нахождения количества всех положительных элементов массива

28 Мая 2020 в 19:40
98 +1
0
Ответы
1

sure, here is an example of a program in Python that calculates the number of positive elements in an array:

def count_positive_elements(arr):
count = 0
for i in arr:
if i > 0:
count += 1
return count
# Example array
arr = [1, -2, 3, -4, 5, 6, -7, 8, 9]
result = count_positive_elements(arr)
print(f'The number of positive elements in the array is: {result}')

You can adjust the arr array with your own values to test the program. This program will count the number of positive elements in the array and print the result.

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