标签:die soft ali lin text 遍历 pre overflow san
??正向遍历和单链表相同,详情见单链表。
1/*
2 *pH : 头节点
3 *return 返回尾部节点地址
4 */
5struct node * list_for_each(struct *pH)
6{
7 struct node *p = pH;
8 if(NULL == p)
9 return NULL;
10 while(NULL != p ->pNext)
11 {
12 p = p ->pNext;
13 printf("dtat = %d.\n",p->data);
14 }
15 return p;
16}
1void list_for_reverse(struct node *pTail)
2{
3 struct node *p = pTail; //尾部节点
4 while(NULL != p -> pPrev)
5 {
6 printf("data = %d.\n", p->data); //先打印,逆向遍历,第一个节点就是有效节点
7 p = p ->pPrev;
8 }
9
10}
标签:die soft ali lin text 遍历 pre overflow san
原文地址:https://www.cnblogs.com/ywx123/p/10252402.html