SHARE
TWEET

Number 2

a guest Nov 13th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. n = int(input())
  2. a = ['None']*n
  3. a = input().split(' ')
  4. x = int(input())
  5. min = abs(x - int(a[0]))
  6. ind_min = 0
  7. for i in range(1,n):
  8.     if abs(x - int(a[i])) < min:
  9.         min = abs(x - int(a[i]))
  10.         ind_min = i
  11. print(a[ind_min])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top