链表逆序输出
2014-06-20 21:53
253 查看
#include <iostream> #include <cstdio> #include <stdlib.h> using namespace std; struct ListNode { int m_value; ListNode *m_pNext; }; void PrintList(ListNode *pHead); int main() { ListNode *pHead; ListNode *pNode; ListNode *pN; pHead=(ListNode*)malloc(sizeof(ListNode)); pHead->m_pNext=NULL; pNode=pHead; int n; int count=6; while(count--) { pN=(ListNode*)malloc(sizeof(ListNode)); pNode->m_pNext=pN; pNode=pN; scanf("%d",&n); pNode->m_value=n; } pNode->m_pNext=NULL; PrintList(pHead->m_pNext); return 0; } void PrintList(ListNode *pHead) { if(pHead!=NULL) { if(pHead->m_pNext!=NULL) PrintList(pHead->m_pNext); printf("%d\n",pHead->m_value); } }
相关文章推荐
- 单链表[建表、输出、插入、删除、逆序]
- 链表元素的逆序输出
- 华为机试—逆序链表输出
- 将一个链表逆序并输出
- 单链表逆序输出的几种实现方式
- [华为机试练习题]24.删除链表中的反复节点、剩余节点逆序输出
- 链表的建立、输出、逆序
- 剑指Offer03 逆序输出链表&链表逆序
- C语言 将链表中的元素在同一个链表中逆序输出
- [记着玩]java模拟链表逆序输出结果
- 数据结构之头指针链表的逆序、输出和指定位置的删除
- 链表递归逆序输出和反转链表。
- 逆序输出链表元素
- java版的单向链表的逆序输出
- 单向链表(四) 修改指定节点的数据值、逆序输出
- 链表创建 然后逆序 然后输出 上机测试题
- 链表的逆序输出
- 【链表】逆序输出
- 链表逆序输出(递归妙)
- 逆序输出链表