【发布时间】:2013-06-02 09:38:21
【问题描述】:
我刚刚尝试了一个反向打印单数链表的程序。
假设链表已准备好包含 5 个元素:
1->2->3->4->5
我编写了一个以相反顺序打印的程序,例如:5 4 3 2 1
但我的程序只是打印为5 4 3 2; 1 没有打印。为什么?
int Reverse_List(abc_t *pNode) {
abc_t *pTemp;
int count = 5;
if (pNode->pNext != NULL) {
pNode = pNode->pNext;
Reverse_List(pNode);
printf("The node is %d\n", pNode->a);
}
}
【问题讨论】:
-
the 1 is not printing. Why?printf("The node is %d\n",pNode->a);pNode 是 pNode->pNext -
建议:不需要
int count和abc_t *pTemp
标签: c recursion singly-linked-list