这是我自己写的有关于二叉树线索化与遍历的算法,不知道为什么无法打印出我输入的字符,而且还出错,请哪位高手指点一下,感激不尽!
struct ThreadNode
{
    int ltag,rtag;
    char data;
    ThreadNode *lchild,*rchild;
};
ThreadNode *pre=NULL;
void Prethread(ThreadNode *T)//前序线索化二叉树
{
    ThreadNode *p=T;
    if(p)
    {
        if(pre==NULL)

        if(p->lchild==NULL)
        {
            p->ltag=1;
            p->lchild=pre;
        }
        else
        {
            p->ltag=0;
        }
        if(pre!=NULL)
        {
            if(pre->rchild==NULL)
            {
                pre->rtag=1;
                pre->rchild=p;
            }
            else
                pre->rtag=0;
        }
        pre=p;
        Prethread(p->lchild);
        Prethread(p->rchild);
    }
}
void PreThrough(ThreadNode *T)//前序遍历
{
    ThreadNode *p=T;
    while(p)
    {
        cout<<p->data<<"   ";
        if(p->ltag==0)
            p=p->lchild;
        else
            p=p->rchild;
    }
}