File tree Expand file tree Collapse file tree 4 files changed +28
-3
lines changed Expand file tree Collapse file tree 4 files changed +28
-3
lines changed Original file line number Diff line number Diff line change 1
1
# depslib dependency file v1.0
2
- 1493901893 source:c:\users\dell\desktop\curriculum\semester_4\datastructure\algorithm\experiment\experiment07\main.cpp
2
+ 1494328039 source:c:\users\dell\desktop\curriculum\semester_4\datastructure\algorithm\experiment\experiment07\main.cpp
3
3
<iostream>
4
4
<fstream>
5
5
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" UTF-8" standalone =" yes" ?>
2
2
<CodeBlocks_layout_file >
3
3
<ActiveTarget name =" Debug" />
4
- <File name =" main.cpp" open =" 1" top =" 1 " tabpos =" 1" split =" 0" active =" 1" splitpos =" 0" zoom_1 =" 2 " zoom_2 =" 0" >
4
+ <File name =" main.cpp" open =" 1" top =" 0 " tabpos =" 1" split =" 0" active =" 1" splitpos =" 0" zoom_1 =" 5 " zoom_2 =" 0" >
5
5
<Cursor >
6
- <Cursor1 position =" 0 " topLine =" 56 " />
6
+ <Cursor1 position =" 1781 " topLine =" 67 " />
7
7
</Cursor >
8
8
</File >
9
9
</CodeBlocks_layout_file >
Original file line number Diff line number Diff line change @@ -83,11 +83,36 @@ void midtravel(SBiT root)
83
83
p = next (p);
84
84
}
85
85
}
86
+ // 最后一个元素
87
+ SBiT last (SBiT p)
88
+ {
89
+ while (p && p->rtag == LINK)
90
+ p = p->rchild ;
91
+ return p;
92
+ }
93
+ // 找到前驱节点
94
+ SBiT previous (SBiT p)
95
+ {
96
+ if (p->ltag == THREAD)
97
+ return p->lchild ;
98
+ return last (p->lchild );
99
+ }
100
+ void midtravel2 (SBiT root)
101
+ {
102
+ SBiT p = last (root);
103
+ while (p)
104
+ {
105
+ cout << p->data ;
106
+ p = previous (p);
107
+ }
108
+ }
86
109
int main ()
87
110
{
88
111
SBiT root = create (),pre = NULL ;;
89
112
midThreading (root, pre);
90
113
pre->rtag = THREAD;
91
114
midtravel (root);
115
+ cout << endl;
116
+ midtravel2 (root);
92
117
return 0 ;
93
118
}
You can’t perform that action at this time.
0 commit comments