typedef int ElemType; typedef struct Lnode{ ElemType data; struct Lnode* next; }Lnode,*LinkLnode;
LinkLnode InitLnode(){ LinkLndoe p; LinkLnode temp = (LinkLnode)malloc(sizeof(Lnode)); temp->data = NULL; temp->next = NULL; P = temp; return p; }
LinkLnode InsertLnode(LinkLnode l, int add, ElemType e){ LinkLnode temp = NULL ; temp = l; if(add<1){ printf("插入有问题"); return l; } for(int i = 1;i < add;i++){ if(temp==NULL){ printf("插入有问题"); return l; } temp = temp->next; } LinkLnode c = (LinkLnode)malloc(sizeof(Lnode)); c->data = e; c->next = temp->next; temp->next = c; return l; }
原文:https://www.cnblogs.com/chaogechaoge/p/13127075.html