午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

您的位置:首頁技術文章
文章詳情頁

python操作鏈表的示例代碼

瀏覽:18日期:2022-07-09 17:20:19

class Node: def __init__(self,dataval=None): self.dataval=dataval self.nextval=Noneclass SLinkList: def __init__(self): self.headval=None # 遍歷列表 def traversal_slist(self): head_node=self.headval while head_node is not None: print(head_node.dataval) head_node=head_node.nextval# 表頭插入結點 def head_insert(self,newdata): Newdata=Node(newdata) Newdata.nextval=self.headval self.headval=Newdata # 表尾插入結點 def tail_insert(self,newdata): Newdata=Node(newdata) if self.headval is None: self.headval=Newdata return head_node = self.headval while head_node.nextval : head_node=head_node.nextval head_node.nextval=Newdata# 在兩個數(shù)據(jù)結點之間插入 def middle_insert(self,middle_node,newdata): Newdata=Node(newdata) if middle_node is None: return Newdata.nextval=middle_node.nextval middle_node.nextval=Newdata# 刪除結點 def remove_node(self,newdata): head_node=self.headval if head_node==None: return if head_node.dataval == newdata: self.headval = head_node.nextval head_node = None return while head_node is not None: prev=head_node head_node=head_node.nextval if head_node:if head_node.dataval==newdata: prev.nextval=head_node.nextval lis=SLinkList()lis.headval=Node(’aa’)ee=Node(’bb’)lis.headval.nextval=eelis.head_insert(’cc’)lis.tail_insert(’dd’)lis.middle_insert(ee,'Fri')lis.remove_node(’bb’)lis.traversal_slist()

以上就是python操作鏈表的示例代碼的詳細內(nèi)容,更多關于Python鏈表的資料請關注好吧啦網(wǎng)其它相關文章!

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 伊人久久网站 | 色先锋在线 | 久久九九精品 | 国产视频第一区 | 欧美成人aaa | 色优久久 | 国产精品久久久久久在线观看 | 国产综合日韩 | 国产欧美精品区一区二区三区 | 在线中文字幕日韩 | 中文字幕欧美一区 | 亚洲人在线 | 裸体男女树林做爰 | 一呦二呦三呦精品网站 | 欧美 中文字幕 | 天天干天天干天天干 | 在线观看国产视频 | 永久免费看mv网站入口亚洲 | 手机在线观看av网站 | 国产一区二区三区四区在线 | 中文字幕久久久 | 超碰不卡 | 天堂在线www | 在线观看免费国产 | 不戴套各种姿势啪啪高素质 | 精品毛片在线观看 | 亚洲 欧美 中文字幕 | 日韩视频免费 | 少妇特黄a一区二区三区 | 亚洲欧美日韩偷拍 | 国产精品一区二区三区在线免费观看 | 99精品在线观看视频 | 日韩一区二区三区免费观看 | 偷拍青青草 | 日韩一区二 | 欧美日韩中文字幕在线 | 91久久久久久久久久 | 日本精品视频在线观看 | 国产在线一级 | 伊人网狼人 | 丰满少妇久久久久久久 |