Advertisement
boris-vlasenko

zad1

Mar 22nd, 2019
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. from random import randrange
  2. N = int(input())
  3. A = int(input())
  4. B = int(input())
  5.  
  6. a = [randrange(A,B+1) for i in range(N)]
  7. print('Source list:')
  8. print(a)
  9. fn = None
  10. ln = None
  11. for i in range(N):
  12.     if a[i] < 0:
  13.         if fn is None:
  14.             fn = i
  15.         ln = i
  16.  
  17. if ln and fn and fn < ln:  
  18.     res = a[fn+1:ln]
  19.     print('First negative:',a[fn])
  20.     print('Last negative:',a[ln])
  21.     print('Result:')
  22.     print(res)
  23. else:
  24.     print('Отрицательных меньше двух')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement