首页 > 代码库 > 链表反向输出

链表反向输出

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();	}}

  

链表反向输出