All pastes #985654 Raw Edit

Mine

public cpp v1 · immutable
·published 2008-04-15 06:13 UTC
rendered paste body
	void reverse() {		// Trivial base case: empty list.		if (head == NULL)			return;		LNode *current = head;		LNode *prev = NULL;		while (current != NULL) {			// Remember which node is next before we clobber the link.			LNode *next = current->next;			// Reverse the link.			current->next = prev;			// Shift prev-current-next window.			prev = current;			current = next;		}		// At the end, prev is actually the last node because of		// "prev = current" above.		head = prev;	}