struct ListNode { int m_nKey; ListNode *m_pNext; }; void printListReversingly(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_nKey); nodes.pop(); } }
时间: 2024-10-03 11:09:38