RosettaCodeData/Task/Parametric-polymorphism/FreeBASIC/parametric-polymorphism.basic

21 lines
450 B
Plaintext

Type BinaryTree
valor As Integer
izda As BinaryTree Ptr
dcha As BinaryTree Ptr
End Type
Sub PrintTree(t As BinaryTree Ptr, depth As Integer)
If t = 0 Then Exit Sub
Print String(depth, Chr(9)); t->valor
PrintTree(t->izda, depth + 1)
PrintTree(t->dcha, depth + 1)
End Sub
Dim As BinaryTree b = Type(6)
Dim As BinaryTree bLeft = Type(5)
Dim As BinaryTree bRight = Type(7)
b.izda = @bLeft
b.dcha = @bRight
PrintTree(@b, 0)