Дан список чисел. Если в нем есть два соседних элемента одного знака, выведите эти числа. Если сосед
Python
# Считываем список чисел
numbers = [int(x) for x in input("Введите список чисел через пробел (завершите 0): ").split()]
# Ищем два соседних элемента одного знака
for i in range(len(numbers) - 1):
if (numbers[i] > 0 and numbers[i + 1] > 0) or (numbers[i] < 0 and numbers[i + 1] < 0):
print(numbers[i], numbers[i + 1])
break
Output
Embed on website
To embed this program on your website, copy the following code and paste it into your website's HTML:
Comments
This comment belongs to a banned user and is only visible to admins.
This comment belongs to a deleted user and is only visible to admins.