#GESP4069. [GESP]L5-202606-Q4069-S
[GESP]L5-202606-Q4069-S
下面代码遍历并输出一个循环单链表,其中 head 指向链表的第一个节点,横线处应填入的是( )。
struct Node {
int val;
Node* next;
};
void printList(Node* head) {
if (head == nullptr) return;
Node* p = head;
_______________________ // 在此处填入代码
cout << endl;
}
{{ select(1) }}
while (p != nullptr) { cout << p->val << " "; p = p->next; }while (p->next != nullptr) { cout << p->val << " "; p = p->next; }do { cout << p->val << " "; p = p->next; } while (p != head);for (; p; p = p->next) { cout << p->val << " "; }
相关
在下列比赛中: