单链表的逆置打印:
1.递归式:
void PrintTailTOHead(ListNode *&phead) { if(phead) { PrintTailTOHead(phead->_next); cout<<phead->_data<<"->"; } }
2.非递归式:
ListNode* Reverse(ListNode *&pHead)//逆置单链表 { ListNode *cur=pHead; ListNode *newHead=NULL; while(cur) { ListNode *tmp=cur; cur=cur->_next; tmp->_next=newHead; newHead=tmp; } return newHead; }