[原创]单链表逆序
LinkNode* ReverseLink(LinkNode *pLink) { if (pLink->pNext == NULL || pLink == NULL) return pLink; LinkNode *pHead = ReverseLink(pLink->pNext); pLink->pNext->pNext = pLink; pLink->pNext = NULL; return pHead; }
LinkNode* ReverseLink(LinkNode *pLink) { if (pLink->pNext == NULL || pLink == NULL) return pLink; LinkNode *p, *q, *r; p = NULL; q = pLink; r = q->pNext; while (r != NULL) { q->pNext = p; p = q; q = r; r = r->pNext; } q->pNext = p; return q; }