Advertisement
denvolf2000

Задача 5

Dec 16th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. from random import randint
  2.  
  3. A =  [randint(-100, 100) for i in range(25)]
  4. print(A) #для проверки
  5.  
  6. countP = 0 #счетчик для положительных
  7. countMaxP = -1
  8. countO = 0 #счетчик для отрицательных
  9. countMaxO = -1
  10.  
  11. for i in range(len(A)):
  12.     if A[i] > 0:
  13.         countP += 1
  14.         if countMaxO < countO:
  15.             countMaxO = countO
  16.             countO = 0
  17.         else: countO = 0
  18.     elif A[i] < 0:
  19.         countO += 1
  20.         if countMaxP < countP:
  21.             countMaxP = countP
  22.             countP = 0
  23.         else: countP = 0
  24.        
  25. print(max(countMaxP, countMaxO))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement