from random import randint
A = [randint(-10,2) for i in range(int(input("N=")))]
print(A)
idx = -1
for i in range(len(A)):
if A[i] > 0:
idx = i
break
if idx == -1:
print("Положительных элементов нет!")
else:
for i in range(idx, len(A)):
if A[i] < 0:
A[i] *= -1
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
from random import randint
A = [randint(-10,2) for i in range(int(input("N=")))]
print(A)
idx = -1
for i in range(len(A)):
if A[i] > 0:
idx = i
break
if idx == -1:
print("Положительных элементов нет!")
else:
for i in range(idx, len(A)):
if A[i] < 0:
A[i] *= -1
print(A)