kburnik

Logo - Binarna pretraga

Oct 27th, 2012
104
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. to binarno :s :e :p :n :cmp
  2.  
  3. while [ (:e-:s) > :p ] [
  4. localmake "t (:s+:e)/2
  5. localmake "usp run (list :cmp :t :n)
  6. ifelse ((abs :usp) <= :p) [
  7. op :t
  8. ][
  9. ifelse :usp < 0 [
  10. make "s :t
  11. ] [
  12. make "e :t
  13. ]
  14. ]
  15. ]
  16.  
  17. op :t
  18.  
  19. end
  20.  
  21. to usp :t :n
  22. op (:t*:t - :n)
  23. end
  24.  
  25. to korijen :n
  26. op binarno 1 :n 0.0000000001 :n "usp
  27. end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×