StackNode reverse(StackNode phead)
{
if (phead == NULL){ return NULL; }
if (phead->pNext == NULL) { return phead; }
StackNode* pre, *cur, *next;
cur = phead->pNext;
phead->pNext = NULL;
pre = phead;
while (cur != NULL)
{
next = cur->pNext;
cur->pNext = pre;
pre = cur;
cur = next;
}
phead = pre;
return phead;
}
原文地址:http://blog.51cto.com/12211918/2105941