Skip to content

Commit 0a00b20

Browse files
committed
add some functions
1 parent 8ffc6a2 commit 0a00b20

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# 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
33
<iostream>
44
<fstream>
55

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
22
<CodeBlocks_layout_file>
33
<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">
55
<Cursor>
6-
<Cursor1 position="0" topLine="56" />
6+
<Cursor1 position="1781" topLine="67" />
77
</Cursor>
88
</File>
99
</CodeBlocks_layout_file>

experiment/experiment07/main.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,36 @@ void midtravel(SBiT root)
8383
p = next(p);
8484
}
8585
}
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+
}
86109
int main()
87110
{
88111
SBiT root = create(),pre = NULL;;
89112
midThreading(root, pre);
90113
pre->rtag = THREAD;
91114
midtravel(root);
115+
cout << endl;
116+
midtravel2(root);
92117
return 0;
93118
}
906 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)