Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
32
Task/Visualize-a-tree/Yabasic/visualize-a-tree.basic
Normal file
32
Task/Visualize-a-tree/Yabasic/visualize-a-tree.basic
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
clear screen
|
||||
|
||||
dim colore$(1)
|
||||
|
||||
maxCol = token("white yellow cyan green red", colore$())
|
||||
|
||||
showTree(0, "[1[2[3][4[5][6]][7]][8[9]]]")
|
||||
print "\n\n\n"
|
||||
showTree(0, "[1[2[3[4]]][5[6][7[8][9]]]]")
|
||||
|
||||
sub showTree(n, A$)
|
||||
local i, c$
|
||||
static co
|
||||
|
||||
c$ = left$(A$, 1)
|
||||
|
||||
if c$ = "" return
|
||||
|
||||
switch c$
|
||||
case "[": co = co + 1 : showTree(n + 1, right$(A$, len(A$) - 1))
|
||||
break
|
||||
case "]": co = co - 1 : showTree(n - 1, right$(A$, len(A$) - 1))
|
||||
break
|
||||
default: for i = 2 to n
|
||||
print " ";
|
||||
next i
|
||||
co = max(min(co, maxCol), 1)
|
||||
print color(colore$(co)) "\xc0-", c$
|
||||
showTree(n, right$(A$, len(A$) - 1))
|
||||
break
|
||||
end switch
|
||||
end sub
|
||||
Loading…
Add table
Add a link
Reference in a new issue