Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
31
Task/Visualize-a-tree/FreeBASIC/visualize-a-tree.basic
Normal file
31
Task/Visualize-a-tree/FreeBASIC/visualize-a-tree.basic
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
Dim Shared As Ubyte colores(4) => {7,13,14,3,2}
|
||||
|
||||
Sub showTree(n As Integer, A As String)
|
||||
Dim As Integer i, co = 0, b = 1, col
|
||||
Dim As String cs = Left(A, 1)
|
||||
|
||||
If cs = "" Then Exit Sub
|
||||
|
||||
Select Case cs
|
||||
Case "["
|
||||
co += 1 : showTree(n + 1, Right(A, Len(A) - 1))
|
||||
Exit Select
|
||||
Case "]"
|
||||
co -= 1 : showTree(n - 1, Right(A, Len(A) - 1))
|
||||
Exit Select
|
||||
Case Else
|
||||
For i = 2 To n
|
||||
Print " ";
|
||||
co = n
|
||||
Next i
|
||||
Color colores(co) : Print !"\&hc0-"; cs
|
||||
showTree(n, Right(A, Len(A) - 1))
|
||||
Exit Select
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Cls
|
||||
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]]]]")
|
||||
Sleep
|
||||
Loading…
Add table
Add a link
Reference in a new issue