typedef struct LNode{
int data;
struct LNode *next;
}LNode, *LinkList;
//初始化单链表(带头结点)
bool InitList(LinkList &L){
L = (LNode *) malloc(sizeof(LNode));
if(L==NUll)
return false;
L->next = NULL;
return true;
}
//后插操作:在p结点之后插入元素e
bool InsertNextNode(LNode *p, int e){
if(p==NULL)
return false;
LNOde *s = (LNode *) malloc(sizeof(LNode));
if(s==NULL)
return false;
s->data = e;
s->next = p->next;
p->next = s;
return true;
}
数据结构:尾插法建立单链表
最新推荐文章于 2024-06-25 07:11:52 发布