单向链表的基本操作
1. 单向链表的建立
NODE* AppendNode(NODE *head, int nodedata)
{
NODE* p = NULL, *pr = head;
p = (NODE*)malloc(sizeof(NODE));
if(p == NULL)
{
printf("error!");
exit(0);
}
p->data = nodedata;
p->next = NULL;
if(head == NULL)
head = p;
else
{
while(pr->next != NULL)
{
pr = pr->next;
}
pr->next = p;
}
return head;
}
2.单向链表的删除
NODE* Delete(NODE* head , int nodedata)
{
NODE* p = head, *pr = head;
if(head == NULL)
return head;
while(p->next != NULL && p->data != nodedata)
{
pr = p;
p