链表逆序算法实现

链表逆序算法实现

TYPE *reverse(TYPE *head)
{
	TYPE *pf=NULL,*pb=NULL,*pr=NULL;
	
	pf = head;
	pb=pf->next;
	while(pb != NULL)
	{
		pr = pb->next;
		pb->next = pf;
		pf = pb;
		pb = pr;
	}
	head->next = NULL;
	head=pf;
	
	return head;
}

链表清空算法实现

void Link_delete(TYPE *head)
{
	TYPE *pb = NULL;
	pb = head;
	
	while(head != NULL)
	{
		head=head->next;
		free(pb);
		pb = head;
	}
}
    原文作者:田园诗人之园
    原文地址: https://blog.csdn.net/u014100559/article/details/82971281
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞