/*翻转单链表*/ void reverseLink(LinkNode *& pHead) { if(pHead == NULL) return; LinkNode *pre,*cur,*next; pre = pHead; cur = pHead->_next; pre->_next = NULL; while(cur != NULL) { next = cur->_next; cur->_next = pre; pre = cur; cur = next; } pHead = pre; } int main() { LinkNode * pHead = 0; int a[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14}; for (int i = 0; i<sizeof(a) / sizeof(a[0]); i++) { createLink(pHead,a[i]); } printLink(pHead); reverseLink(pHead); printLink(pHead); return 0; }