摘要:[Visual Basic 6.0] 資料結構 利用一維陣列模擬多元樹 (N Tree) (二元樹、三元樹、N元樹) 與樹狀搜尋
[Visual Basic 6.0] 資料結構 利用一維陣列模擬多元樹 (N Tree) (二元樹、三元樹、N元樹) 與樹狀搜尋
'# [Visual Basic 6.0] 資料結構 利用一維陣列模擬多元樹 (二元樹、三元樹、N元樹) 與樹狀搜尋
'# 0xDe
Private Sub Command1_Click()
Aans = 1 ' 層
Bans = 1 ' 個
Cans = 0 ' 左右
atree = Split(Text2, " ")
k = 1
For i = 0 To UBound(atree)
If atree(i) = Text3.Text Then
If Cans = 0 Then
MsgBox "第" & Aans & "層 第" & Bans & "個的左邊": Exit Sub
Else
MsgBox "第" & Aans & "層 第" & Bans & "個的右邊": Exit Sub
End If
End If
a = a + 1
Cans = Cans + 1
If Cans > 1 Then Cans = 0: Bans = Bans + 1
If a = k Then
Aans = Aans + 1 ' 層
Bans = 1 ' 個
Cans = 0 ' 左右
If k = 1 Then k = k * Text1 Else k = k * 2
a = 0
End If
Next i
MsgBox "樹中找不到元素"
End Sub
Private Sub Command2_Click()
atree = Split(Text2, " ")
Picture1.Cls
k = 1
For i = 0 To UBound(atree)
Picture1.Print atree(i) & " ";
a = a + 1
If a = k Then
Picture1.Print
If k = 1 Then k = k * Text1 Else k = k * 2
a = 0
End If
Next i
End Sub
[Visual Basic 6.0] 資料結構 利用一維陣列模擬多元樹 (二元樹、三元樹、N元樹) 與樹狀搜尋.rar
#0xDe 從分享中學習
#Facebook:ProgrammerDe (https://www.facebook.com/MicrosoftDes) 有問題歡迎提問