AI题库 · GESP-Python五级题库
题目分享 #16974
对如下定义的循环单链表,`print_list` 函数横线处填写()。
class Node:
def __init__ (self , data) :
self.data = data
self.next = None
def create_list(value) :
head = Node(value)
head.next = head
return head
def insert_tail(head , value) :
p = head
while p.next != head:
p = p.next
node = Node(value)
node.next = head
p.next = node
def print_list(head) :
# 填空位置
while True:
print(p.data , end=" ")
p = p.next
if p == head :
break
print()
A
if head is None: return p.next = head
B
if head is None: return p = head.next
C
if head is None: return p = head
D
if head.next is None: return p = head
AI题库 · 编程考级与信奥赛真题库
查看答案 →
复制链接后可在微信、QQ、小红书等平台粘贴分享;答案与解析在题目页。