‹ 上一题 下一题 ›

g5-04202. GESP-5级-2024-03-单选-第04题 未做

1000 ms 256 MB 测试点 ? GESPGESP-52024-03单选客观题5级·链表链表

下面的代码片段用于在双向链表中删除一个节点。请在横线处填入( ),使其能正确实现相应功能。

void deleteNode(DoublyListNode*& head, int value) {
    DoublyListNode* current = head;
    while (current != nullptr && current->val != value) {
        current = current->next;
    }
    if (current != nullptr) {
        if (current->prev != nullptr) {
            ____________ // 在此处填入代码
        } else {
            head = current->next;
        }
        if (current->next != nullptr) {
            current->next->prev = current->prev;
        }
        delete current;
    }
}
  • A. if (current->next != nullptr) current->next->prev = current->prev;
  • B. current->prev->next = current->next;
  • C. delete current->next;
  • D. current->prev = current->next;
未选择
输入
输出

            
答案