1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
1
/****************************************
2 > File Name:stack_test.cpp
3 > Author:xiaoxiaohui
4 > mail:1924224891@qq.com
5 > Created Time:2016年05月19日 星期四 21时01分44秒
6 ****************************************/
7
8 #include<iostream>
9
using
namespace
std
10
11
void
print(ListNode* phead)
12 {
13 stack<ListNode*> node;
14
15 ListNode* tem = phead;
16
while
(tem != NULL)
17 {
18 node.push(tem);
19 tem = tem->m_pNext;
20 }
21
22
while
(!node.empty())
23 {
24 tem = node.top();
25
printf
(
"%d "
, tem->m_nValue);
26 node.pop();
27 }
28 }
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
1
/****************************************
2 > File Name:digui_test.c
3 > Author:xiaoxiaohui
4 > mail:1924224891@qq.com
5 > Created Time:2016年05月19日 星期四 20时48分02秒
6 ****************************************/
7
8 #include<stdio.h>
9
10
void
print(ListNode* phead)
11 {
12 ListNode* tem = phead;
13
if
(tem == NULL)
14 {
15
return
;
16 }
17
else
18 {
19 print(tem->m_pNext);
20
printf
(
"%d "
,tem->m_nKey);
21 }
22 }
|
本文转自 ye小灰灰 51CTO博客,原文链接:http://blog.51cto.com/10704527/1783632,如需转载请自行联系原作者