树的非递归遍历(就离谱)


void InorderTraversal( BinTree BT )
{
BinTree T = BT;
Stack S = CreateStack();
while(T!=NULL || !IsEmpty(S));
{
while(T != NULL)
{
Push(S,T);
T = T->Left;
}
T = Pop(S);
printf(" %c",T->Data);
T = T->Right;
}
}

void PreorderTraversal( BinTree BT )
{
BinTree T = BT;
Stack S = CreateStack();
while(T || !IsEmpty(S));
{
while(T)
{
printf(" %c",T->Data);
Push(S,T);
T = T->Left;
}
T = Pop(S);
T = T->Right;
}
}

void PostorderTraversal( BinTree BT )
{
BinTree T = BT;
Stack S = CreateStack();
while(T || !IsEmpty(S))
{
while(T != NULL)
{
Push(S,T);
T->flag = 0;
T = T->Left;
}
T = Peek(S);
if(T->flag==0)
{
T->flag = 1;
T = T->Right;
}
else
{
printf(" %c",T->Data);
T = Pop(S);
T = NULL;
}
}
}//引起我找了几个小时的bug竟然只是一个括号!!!!!!!!!!!!!!!!!!!!!!!!!!!!
}