From 74a820ec913cc3a8e4e140c3bd8c87ab3b39d51e Mon Sep 17 00:00:00 2001 From: bala <13452927+rfgsdhshgfh@user.noreply.gitee.com> Date: Sat, 13 Jan 2024 14:35:14 +0000 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E5=8D=95=E9=93=BE=E8=A1=A8=E6=8C=89?= =?UTF-8?q?=E5=9F=BA=E5=87=86=E5=88=92=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: bala <13452927+rfgsdhshgfh@user.noreply.gitee.com> --- ...2\345\207\206\345\210\222\345\210\206.cpp" | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 "2224020152/\347\254\254\344\272\214\345\215\225\345\205\203/\345\260\206\345\215\225\351\223\276\350\241\250\346\214\211\345\237\272\345\207\206\345\210\222\345\210\206.cpp" diff --git "a/2224020152/\347\254\254\344\272\214\345\215\225\345\205\203/\345\260\206\345\215\225\351\223\276\350\241\250\346\214\211\345\237\272\345\207\206\345\210\222\345\210\206.cpp" "b/2224020152/\347\254\254\344\272\214\345\215\225\345\205\203/\345\260\206\345\215\225\351\223\276\350\241\250\346\214\211\345\237\272\345\207\206\345\210\222\345\210\206.cpp" new file mode 100644 index 00000000..fc2a5e45 --- /dev/null +++ "b/2224020152/\347\254\254\344\272\214\345\215\225\345\205\203/\345\260\206\345\215\225\351\223\276\350\241\250\346\214\211\345\237\272\345\207\206\345\210\222\345\210\206.cpp" @@ -0,0 +1,30 @@ +bool DivideList(LinkNode*& L, ElemType x) +{ + if (L->next==NULL) { + printf("单链表不存在。\n"); + return false; + } + LinkNode* p = NULL, * q = NULL, * r = NULL; + p = L; + + while (!q) { + q = (LinkNode*)malloc(sizeof(LinkNode)); + } + r = q; + + while (p->next) { + if (p->next->data < x) { + r->next = p->next; + r=r->next; + p->next= p->next->next; + r->next = NULL; + } + else + p = p->next; + } + + r->next = L->next; + L->next = q->next; + free(q); + return true; +} -- Gitee