单链表的反转(转置)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_40990854/article/details/82768275
template<class Type>
inline void Link<Type>::InverseLink()
{
	Node<Type> * current = head;
	Node<Type> * next = NULL;
	Node<Type> * result = NULL;
	while ( current )
	{
		next = current->next;
		current->next = result;
		result = current;
		current = next;
	}
	head = result;
}

猜你喜欢

转载自blog.csdn.net/qq_40990854/article/details/82768275