阅读背景:

链表的相关算法及应用(一)

来源:互联网 

1.逆置链表(递归、迭代两种方法)

2.逐对逆置链表(递归、迭代)

 

// 逆置链表	迭代 
LNode *reverse(LinkList &L){
	LNode *pre=NULL;
	LNode *cur=L->next;
	LNode *t;
	while(cur){
		t=cur->next;
		cur->next=pre;
		pre=cur;
		cur=t;
	}
	LNode *newHead = (LNode*)malloc(sizeof(LNode));	//创建新的头结点 
	newHead->next=pre;
	return newHead;		//返回新的头结点 
} 
//



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: