璐村惂鐢ㄦ埛_007ZKQU馃惥
-
关注数: 0
粉丝数: 4
发帖数: 258
关注贴吧数: 0
Splay Tree For VB6 - 未完成 以下是一个 Class, 名叫 CSplayOption ExplicitPrivate Type TNode lChild As Long rChild As Long Father As Long Key As LongEnd TypeDim Root As Long, Node() As TNode, MaxNode As LongDim FreeMemList() As Long, FreeMemCount As LongPrivate Sub Class_Initialize() ReDim Node(16), FreeMemList(16) Root = 0: MaxNode = 0: FreeMemCount = 0End SubPublic Sub Add(ByVal Key As Long) Dim NodeNumber As Long, UBoundNode As Long, Pos As Long, GoLeft As Boolean If FreeMemCount = 0 Then MaxNode = MaxNode + 1 NodeNumber = MaxNode Else MaxNode = FreeMemList(FreeMemCount) FreeMemCount = FreeMemCount - 1 End If UBoundNode = UBound(Node) If NodeNumber > UBoundNode Then ReDim Preserve Node(UBoundNode * 2) With Node(NodeNumber) .Key = Key .lChild = 0 .rChild = 0 End With If Root = 0 Then Root = NodeNumber Node(NodeNumber).Father = 0 Else Pos = Root GoLeft = Key < Node(Pos).Key Do While (GoLeft And (Node(Pos).lChild <> 0)) Or ((Not GoLeft) And (Node(Pos).rChild <> 0)) If GoLeft Then Pos = Node(Pos).lChild Else Pos = Node(Pos).rChild GoLeft = Key < Node(Pos).Key Loop If GoLeft Then Node(Pos).lChild = NodeNumber Else Node(Pos).rChild = NodeNumber Node(NodeNumber).Father = Pos Splay Pos End IfEnd SubPublic Sub MidOrder(Optional ByVal Pos As Long = -1) If Pos = -1 Then Pos = Root If Pos = 0 Then Exit Sub MidOrder Node(Pos).lChild MsgBox Node(Pos).Key MidOrder Node(Pos).rChildEnd SubPrivate Sub Left_Rotate(ByVal Pos As Long) Dim t As Long t = Node(Pos).Key: Node(Pos).Key = Node(Node(Pos).rChild).Key: Node(Node(Pos).rChild).Key = t t = Node(Pos).lChild: Node(Pos).lChild = Node(Pos).rChild: Node(Pos).rChild = t t = Node(Pos).rChild: Node(Pos).rChild = Node(Node(Pos).lChild).rChild Node(Node(Pos).lChild).rChild = Node(Node(Pos).lChild).lChild: Node(Node(Pos).lChild).lChild = t Node(Node(Pos).lChild).Father = Pos: Node(Node(Pos).rChild).Father = Pos Node(Node(Node(Pos).lChild).lChild).Father = Node(Pos).lChild Node(Node(Node(Pos).lChild).rChild).Father = Node(Pos).lChildEnd SubPrivate Sub Right_Rotate(ByVal Pos As Long) Dim t As Long t = Node(Pos).Key: Node(Pos).Key = Node(Node(Pos).lChild).Key: Node(Node(Pos).lChild).Key = t t = Node(Pos).lChild: Node(Pos).lChild = Node(Pos).rChild: Node(Pos).rChild = t t = Node(Pos).lChild: Node(Pos).lChild = Node(Node(Pos).rChild).lChild Node(Node(Pos).rChild).lChild = Node(Node(Pos).rChild).rChild: Node(Node(Pos).rChild).rChild = t Node(Node(Pos).lChild).Father = Pos: Node(Node(Pos).rChild).Father = Pos Node(Node(Node(Pos).rChild).lChild).Father = Node(Pos).rChild Node(Node(Node(Pos).rChild).rChild).Father = Node(Pos).rChildEnd SubPrivate Sub Splay(ByVal Pos As Long) Dim LowerChild As Boolean, UpperChild As Boolean Do While Pos <> Root If Pos = Node(Node(Pos).Father).lChild Then LowerChild = False Else LowerChild = True If Node(Pos).Father = Root Then Pos = Root If LowerChild Then Left_Rotate Pos Else Right_Rotate Pos Else If Node(Pos).Father = Node(Node(Node(Pos).Father).Father).lChild Then UpperChild = True Else UpperChild = False If LowerChild Then If UpperChild Then Pos = Node(Pos).Father: Pos = Node(Pos).Father Left_Rotate Pos: Left_Rotate Pos Else Pos = Node(Pos).Father: Left_Rotate Pos Pos = Node(Pos).Father: Right_Rotate Pos End If Else If UpperChild Then Pos = Node(Pos).Father: Right_Rotate Pos Pos = Node(Pos).Father: Left_Rotate Pos Else Pos = Node(Pos).Father: Pos = Node(Pos).Father Right_Rotate Pos: Right_Rotate Pos End If End If End If LoopEnd Sub
内网互联测试成功。。。 写着玩的。。其实也很简单。。。服务器代码:一个 form 里面放个 wsPrivate Sub Form_Load() On Error GoTo HasError ws.Protocol = sckUDPProtocol ws.Bind 34952 Me.Hide Exit SubHasError: EndEnd SubPrivate Sub ws_DataArrival(ByVal bytesTotal As Long) Dim Data As String On Error GoTo HasError ws.GetData Data, vbString If Data = "show me the address" Then ws.SendData "your address: " & ws.RemoteHostIP & ":" & ws.RemotePort Exit SubHasError: ws.Close DoEvents ws.Bind 34952End Sub客户端代码:一个 form 里面放一个 tmr,一个 wsPrivate Sub Form_Load() tmr.Interval = 1000 ws.Protocol = sckUDPProtocolEnd SubPrivate Sub tmr_Timer() ws.RemoteHost = "vip.366tian.net" ' 你的服务器地址 ws.RemotePort = 34952 ws.SendData "show me the address"End SubPrivate Sub ws_DataArrival(ByVal bytesTotal As Long) ws.GetData Data, vbString lst.AddItem "[" & Time & "] " & Data lst.ListIndex = lst.ListCount - 1End Subiceboy 原创。。。
[源代码更新]可执行文件捆绑器 Z-Bind 2.1
[原创] 使用 VB 制作真正的导出函数 DLL 程序在 icesboy.ys***.com (*** = 168) 里面,叫做 VBLink2.rar使用方法:找到 VB 安装目录,将里面的 Link.exe 改为 Link2.exe,将这个压缩包里的 Link.exe 复制进去生成 DLL 时,即会提示“Link2 检测到生成 DLL”,然后把所有需要导出的函数的函数名添加到列表中。(函数必须放在 Module 中,且必须为 Public)附带源代码和示例文件安装好 Link2 后,生成 Test 中的 DLL 到 C:\Math.dll,注意在导出表中加入 mathadd。然后用 TestEXE 中的程序去调用。注意:生成的 DLL 最好去调 OLE Automation 引用,否则可能无法在没有装 VB 运行库的电脑上运行。
有趣的数字问题...征集解答 100 (10*10) /81 (9*9) =1.234567901234567901...10000 (100*100) /9801 (99*99) = 1.020304050607080909...1000000 / 998001 = 1.002003004005006007008009010011...100000000 / 99980001 = 1.000200030004000500060007000800...10000000000 / 9999800001 = 1.000020000300004000050000600007...... 这是为什么 ...
1
下一页