输入n和n个整数求正数负数和零的个数
时间: 2023-12-13 07:02:51 浏览: 108
输入一个整数判断正负
以下是Python代码:
```python
n = int(input())
nums = list(map(int, input().split()))
positive_count = 0
negative_count = 0
zero_count = 0
for num in nums:
if num > 0:
positive_count += 1
elif num < 0:
negative_count += 1
else:
zero_count += 1
print("positive: {}".format(positive_count))
print("negative: {}".format(negative_count))
print("zero: {}".format(zero_count))
```
输入示例:
```
5
1 2 0 -3 -4
```
输出示例:
```
positive: 2
negative: 2
zero: 1
```
阅读全文