// midorder bianli
void MidOrder(BTree *bt)
{
Inite(s); //inite stack
BTree *p = s;
while (p != NULL || s.empty() != 1)
{
while (p != NULL)
{
s.push(p);
p = p->lchild;
}
if (s.empty() != 1)
{
p = s.top();
visite(p);
s.pop();
p = p->rhild;
}
}
}
// 先序遍历
void PreOrder(BTree *bt)
{
Inite(s); //inite stack
BTree *p = s;
while (p != NULL || s.empty() != 1)
{
while (p != NULL)
{
visite(p);
s.push(p);
p = p->lchild;
}
if (s.empty() != 1)
{
p = s.top();
s.pop();
p = p->rchild;
}
}
}