单选题

下面的函数要实现的功能是删除单向链表中所有值为 value 的节点,请问横线处应该填写( )。

struct Node
{
int val;
Node *nxt;
};
Node* DeleteNode(Node *head, int value)
{
Node *cur, node;
node.nxt = head;
cur = &node;
while(cur->nxt != NULL)
{
_____________________
else
cur = cur->nxt;
}
return node.nxt;
}

A

if(cur->val == value) cur->nxt = cur->nxt->nxt;

B

if(cur->val == value) node.nxt = cur->nxt;

C

if(cur->nxt->val == value) node.nxt = cur->nxt;

D

if(cur->nxt->val == value) cur->nxt = cur->nxt->nxt;

赣ICP备20007335号-2