标签:c++
用栈能很easy的解决,直接贴代码:
struct ListNode{ int m_nValue; ListNode *m_pNext; };
void PrintListRevers(ListNode* pHead) { stack<ListNode*> nodes; ListNode* pNode = pHead; while(pNode != NULL) { nodes.push(pNode); pNode = pNode->m_pNext; } while(!nodes.empty()) { pNode = nodes.top(); printf("%d\t", pNode->m_nValue); nodes.pop(); } }
标签:c++
原文地址:http://blog.csdn.net/lsh_2013/article/details/45232783