Ответ:
from random import choice
def sign(x:int):
if x > 0: return 1
elif x < 0: return -1
else: return 0
N = int(input('Введите размер исходного массива: '))
A = [choice([j for j in range(-100, 100) if j != 0]) for _ in range(N)]
print(A)
chk = sign(A[0])
for i in enumerate(A):
if sign(i[1]) != chk:
print(i[0])
break
chk *= -1
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
from random import choice
def sign(x:int):
if x > 0: return 1
elif x < 0: return -1
else: return 0
N = int(input('Введите размер исходного массива: '))
A = [choice([j for j in range(-100, 100) if j != 0]) for _ in range(N)]
print(A)
chk = sign(A[0])
for i in enumerate(A):
if sign(i[1]) != chk:
print(i[0])
break
chk *= -1