home *** CD-ROM | disk | FTP | other *** search
- '...recursive binary tree using turtle graphics
-
- #include <inputs.h>
-
- sub tree(n)
- if n<5 then exit sub
- turnright 30
- forward n
- tree(n*.75)
- back n
- turnleft 60
- forward n
- tree(n*.75)
- back n
- turnright 30
- end sub
-
- sub usage
- print "usage: tree <depth>"
- end sub
-
- if argcount<>1 then
- ask.depth=-1
- else
- ask.depth=0
- x$=arg$(1)
- if x$="?" then
- usage
- input "enter depth: ",depth
- else
- depth=val(x$) '..get depth
- end if
- end if
-
- screen 1,640,225,2,2
- color 1,0
-
- cls
- locate 1,1
- if ask.depth then
- prints "enter depth: "
- depth=inputs%
- cls
- locate 1,1
- end if
- prints "depth of tree is"
- prints depth
-
- penup
- setxy 320,150
- pendown
-
- tree(depth)
-
- locate 24,1
- prints "press 'q' to quit..."
- while ucase$(inkey$)<>"Q":wend
-
- screen close 1
-