`

链表逆置

阅读更多
/*
 * 链表逆置
 */
public void LinkReverse() {
	LinkNode temp1, temp2, temp3;
	temp1 = head;
	temp2 = temp1.getNext();
	temp3 = temp2.getNext();

	temp1.setNext(null);
	temp2.setNext(temp1);
	while (temp3 != null) {
		temp1 = temp2;
		temp2 = temp3;
		temp3 = temp3.getNext();
		temp2.setNext(temp1);
	}
	head = temp2;
}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics