### 这道题很容易可以想到后进先出的数据结构 ---- 栈,因为我们没有 m_prev 指针。所以遍历时,把节点压栈就好。(这道题用递归代码也很好写) 下面是代码实现(迭代): ``` #include <stack> void printInverse(SList *pHead) { if (pHead == nullptr) { return nullptr; } std::stack<SList *> nodeStack; // 将遍历到的节点入栈 while (pHead != nullptr) { nodeStack.push(pHead); pHead = pHead->m_next; } // 出栈打印 while (!nodeStack.empty()) { SList *topNode = nodeStack.top(); nodeStack.pop(); std::cout << topNode->m_data << " "; } std::cout << endl; } ```