kburnik

LOGO - zadatak Upisuj - rješenje

Dec 7th, 2012
44
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. to upisuj :n :d :k
  2. (local "l "nl "p "a "b "ax "ay "bx "by)
  3.  
  4. make "l []
  5. make "p pos
  6.  
  7. ; prikupi vrhove vanjskog :n-terokuta
  8. pu
  9. repeat :n [
  10. fd :d make "l lput pos :l bk :d rt 360/:n
  11. ]
  12. pd
  13.  
  14. ; crtamo ukupno :k mnogokuta
  15. repeat :k [
  16. ; dodaj prvi vrh na kraj tako da se napravi puni krug
  17. make "l lput (first :l) :l
  18.  
  19. ; pocni od prvog vrha i spoji sve
  20. pu setpos first :l pd
  21. foreach :l [setpos ?]
  22.  
  23. ; priprema za iduci :n-terokut (nova lista je lista polovista)
  24. make "nl []
  25. for [i 1 :n 1] [
  26. ; racunamo poloviste svaka dva susjedna vrha
  27. ; te ga stavljamo na novu listu
  28. ; zadnji vrh na listi :l je jednak prvom (sto i zelimo)!
  29. make "a item :i :l
  30. make "b item :i+1 :l
  31. make "ax first :a make "ay last :a
  32. make "bx first :b make "by last :b
  33. make "nl lput list ((:ax+:bx)/2) ((:ay+:by)/2) :nl
  34. ]
  35.  
  36. ; iduca lista vrhova je novonastala lista polovista
  37. make "l :nl
  38. ]
  39.  
  40. ; vrati se na pocetnu tocku
  41. pu setpos :p pd
  42.  
  43. 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.

×