#创建并输出链表
class Node:
def __init__(self,value=None,next=None):
self.value=value
self.next=next
if __name__ =="__main__":
i = 1
head = Node(None)
head.next = None
cur = head
while i<9:
tmp = Node(i)
tmp.next = None
cur.next = tmp
cur = tmp
i += 1
print("顺序输出:")
cur = head.next
while cur is not None:
print(cur.value, end=" ")
cur = cur.next #结果为1,2,3,4,5,6,7,8
python创建并输出链表
最新推荐文章于 2023-02-17 21:45:00 发布