From cd7b008699d7418973cceef0af7daac826b31adc Mon Sep 17 00:00:00 2001 From: bala <13452927+rfgsdhshgfh@user.noreply.gitee.com> Date: Sat, 13 Jan 2024 14:29:13 +0000 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=8D=95=E9=93=BE=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E5=90=84=E7=A7=8D=E5=9F=BA=E6=9C=AC=E8=BF=90=E7=AE=97?= =?UTF-8?q?=E7=9A=84=E7=AE=97=E6=B3=95?= 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> --- ...7\347\232\204\347\256\227\346\263\225.cpp" | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 "2224020152/\347\254\254\344\272\214\345\215\225\345\205\203/\345\256\236\347\216\260\345\215\225\351\223\276\350\241\250\347\232\204\345\220\204\347\247\215\345\237\272\346\234\254\350\277\220\347\256\227\347\232\204\347\256\227\346\263\225.cpp" diff --git "a/2224020152/\347\254\254\344\272\214\345\215\225\345\205\203/\345\256\236\347\216\260\345\215\225\351\223\276\350\241\250\347\232\204\345\220\204\347\247\215\345\237\272\346\234\254\350\277\220\347\256\227\347\232\204\347\256\227\346\263\225.cpp" "b/2224020152/\347\254\254\344\272\214\345\215\225\345\205\203/\345\256\236\347\216\260\345\215\225\351\223\276\350\241\250\347\232\204\345\220\204\347\247\215\345\237\272\346\234\254\350\277\220\347\256\227\347\232\204\347\256\227\346\263\225.cpp" new file mode 100644 index 00000000..96acd2ed --- /dev/null +++ "b/2224020152/\347\254\254\344\272\214\345\215\225\345\205\203/\345\256\236\347\216\260\345\215\225\351\223\276\350\241\250\347\232\204\345\220\204\347\247\215\345\237\272\346\234\254\350\277\220\347\256\227\347\232\204\347\256\227\346\263\225.cpp" @@ -0,0 +1,128 @@ +#include +#include +typedef char ElemType; +typedef struct LNode +{ + ElemType data; + struct LNode *next; +}LinkNode; +void InitList(LinkNode *&L) +{ + L=(LinkNode *)malloc(sizeof(LinkNode)); + L->next=NULL; +} +bool ListInsert(LinkNode *&L,int i,ElemType e) +{ + int j=0; + LinkNode *p=L,*s; + if(i<=0) + return false; + while(jnext; + } + if(p==NULL) + return false; + else + { + s=(LinkNode *)malloc(sizeof(LinkNode)); + s->data=e; + s->next=p->next; + p->next=s; + return true; + } +} +void DispList(LinkNode *L) +{ + LinkNode *p=L->next; + while(p!=NULL) + { + printf("%c",p->data); + p=p->next; + } + printf("\n"); +} +int ListLength(LinkNode *L) +{ + int n=0; + LinkNode *p=L; + while (p->next!=NULL) + { + n++; + p=p->next; + } + return (n); +} +bool ListEmpty(LinkNode *L) +{ + return (L->next==NULL); +} +bool GetElem(LinkNode *L,int i,ElemType &e) +{ + int j=0; + LinkNode *p=L; + if(i<=0) + return false; + while(jnext; + } + if(p==NULL) + return false; + else + { + e=p->data; + return true; + } +} +int LocateElem(LinkNode *L,ElemType e) +{ + int i=1; + LinkNode *p=L->next; + while(p!=NULL&&p->data!=e) + { + p=p->next; + i++; + } + if(p==NULL) + return (0); + else + return (i); +} +bool ListDelete(LinkNode *&L,int i,ElemType &e) +{ + int j=0; + LinkNode *p=L,*q; + if(i<=0) + return false; + while(jnext; + } + if(p==NULL) + return false; + else + { + q=p->next; + if(q==NULL) + return false; + e=q->data; + p->next=q->next; + free(q); + return true; + } +} +void DestroyList(LinkNode *&L) +{ + LinkNode *pre=L,*p=L->next; + while(p!=NULL) + { + free(pre); + pre=p; + p=pre->next; + } + free(pre); +} -- Gitee