扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:刘涛 来源:yesky 2007年10月14日
关键字:
Public name As String Public id As Integer Public pnext As student |
Private length As Integer Private pfirst As student Property Get first() As student '获取线性表首指针 Set first = pfirst End Property Property Get l() As Integer '获取线性表长度 l = length End Property Public Sub makeempty() '建立一个空的线性表 Dim s As New students.name = "" s.id = 0 Set s.pnext = Nothing Set pfirst = s length = 0 End Sub Public Sub addstudent(ByVal sn As String, ByVal id As Integer) '向线性表中添加一个数据 Dim p As student Set p = pfirst Do While Not p.pnext Is Nothing Set p = p.pnext Loop Set p.pnext = New student p.pnext.name = sn p.pnext.id = id Set p = p.pnext Set p.pnext = Nothing length = length + 1 End Sub Public Function search(ByVal id As Integer) As student '在线性表中搜索一个学生数据 Dim p As student Set p = pfirst Do While p.id <> id And Not p.pnext Is Nothing Set p = p.pnext Loop If Not p.pnext Is Nothing Then Set search = p Else Set search = Nothing End If End Function Public Function delete(ByVal id As Integer) As Boolean '在线性表中删除一个学生数据 Dim p As student Dim cp As student Set p = pfirst Do While p.id <> id And Not p.pnext Is Nothing Set cp = p Set p = p.pnext Loop delete = True If Not p.pnext Is Nothing Then Set p = p.pnext Set cp.pnext = Nothing Set cp.pnext = p length = length - 1 Else delete = False End If End Function |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者