• 2022-06-12 问题

    下列算法的功能是:删除单链表L(含两个或两个以上的数据结点)中第一个值为x的结点的前驱结点。请在空白处选择正确的语句。 int deleteFirstX(LinkList &L, ElemType x) { LinkList prepre = L, pre = prepre->next, p; if (pre->data == x) return 0; p = pre->next; while (p != NULL && p->data != x) { prepre = pre; ____________________; p = p->next; } if (p != NULL) { prepre->next = p; free(pre); return 1; } else return 0; }‏‏‏‏ A: pre = p B: prepre->next = p C: p = pre->next D: p = prepre->next

    下列算法的功能是:删除单链表L(含两个或两个以上的数据结点)中第一个值为x的结点的前驱结点。请在空白处选择正确的语句。 int deleteFirstX(LinkList &L, ElemType x) { LinkList prepre = L, pre = prepre->next, p; if (pre->data == x) return 0; p = pre->next; while (p != NULL && p->data != x) { prepre = pre; ____________________; p = p->next; } if (p != NULL) { prepre->next = p; free(pre); return 1; } else return 0; }‏‏‏‏ A: pre = p B: prepre->next = p C: p = pre->next D: p = prepre->next

  • 1