Advertisement
denvolf2000

Задача 1

Dec 23rd, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. from random import randint
  2.  
  3. A =  [randint(-100, 100) for i in range(25)]
  4.  
  5. print(A) #для проверки
  6.  
  7. countP = 0
  8. countN = 0
  9. countMaxP = 0
  10. countMaxN = 0
  11. i = 0
  12. for i in range(len(A)):
  13.     if A[i] > 0:
  14.         countP += 1
  15.         if countMaxN < countN:
  16.             countMaxN = countN
  17.         countN = 0
  18.     elif A[i] < 0:
  19.         if countMaxP < countP:
  20.             countMaxP = countP
  21.         countP = 0
  22.         countN += 1
  23.     elif A[i] == 0:
  24.         if countMaxN < countN:
  25.             countMaxN = countN
  26.         if countMaxP < countP:
  27.             countMaxP = countP
  28.         countP = 0
  29.         countN = 0
  30. print(max(countMaxN, countMaxP))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement