n = int(input("Array size: "))
a = list(map(int, input("Array elements: ").split()))
cnt = 0
for i in a:
if i < 0:
cnt += 1
print("There are " + str(cnt) + " negative elements in the given array")
Python
n=int(input('Введите кол-во элементов массива : '))
a = list(map(int, input().split()))
print(sum(map(lambda item: item < 0, a)))
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
n = int(input("Array size: "))
a = list(map(int, input("Array elements: ").split()))
cnt = 0
for i in a:
if i < 0:
cnt += 1
print("There are " + str(cnt) + " negative elements in the given array")
Python
n=int(input('Введите кол-во элементов массива : '))
a = list(map(int, input().split()))
print(sum(map(lambda item: item < 0, a)))