放三个人之后长度是多少
运行下面这段程序:
class Node:
def __init__(self, name):
self.name = name
self.next = None
def build(names):
head = None
for x in reversed(names):
nd = Node(x)
nd.next = head
head = nd
return head
head = build(["阿岚", "小满", "阿泰"])
n = 0
cur = head
while cur is not None:
n += 1
cur = cur.next
print(n)
全部评论