逆序输出链表元素
来源:互联网 发布:反还珠 知画重生 编辑:程序博客网 时间:2024/04/28 02:14
关键代码:
struct ListNode{int m_nKey;ListNode* m_pNext;};//法一使用栈的方法 void PrintListReversingly_Iteratively(ListNode* pHead){std::stack<ListNode*> nodes;ListNode* pNode = pHaed;while(pNode!=NULL){nodes.push(pNode);pNode = pNode->m_pNext;}while(!nodes.empty()){pNode = nodes.top;cout << pNode->m_nKey << " ";nodes.pop();}}//法二使用递归的方法//如果链表长度很长,那么存在递归深度过大的问题 void PrintListReversingly_Recursively(ListNode* pHead){if(pHead!=NULL){if(pHead->m_pNext == NULL){cout << pHead->m_nKey << " "; }else{PrintListReversingly_Recursively(pHead->m_pNext);}}}
0 0
- 逆序输出链表元素
- 逆序输出链表的元素
- 逆序输出数组元素
- 数组逆序输出元素
- 逆序输出数组元素
- 逆序输出链表
- 逆序链表输出
- 逆序输出链表
- 链表逆序输出
- 链表逆序输出
- 逆序输出链表
- 逆序输出链表
- C逆序输出数组元素
- 单向链表逆序输出
- 链表的逆序输出
- 逆序输出链表节点
- 递归逆序输出链表
- 链表的逆序输出
- Substring with Concatenation of All Words——解题报告(窗口移动法)
- javascript跨域方法
- ftp主动式连接和被动式连接的却别以及防火墙的设置
- [leetcode][DP] Best Time to Buy and Sell Stock
- 基本绘图-----学习记录(5)
- 逆序输出链表元素
- 文件系统总结1
- 用css3改变背景颜色实现淡入淡出效果
- 用 ElementTree 在 Python 中解析 XML
- NLP的python包:pattern.en
- HDOJ题目2861 Stools(递推)
- 关于C++ const 的全面总结
- Enigma Protector脱壳
- Java写的验证码