先序输入转中序遍历 不知道为什么输入没输出

/*
二叉树扩展先序输入转中序遍历
样例输入
abc##de#g##f###
样例输出
c b e g d f a
样例说明
根据给定的扩展先序遍历序列,建立对应的二叉树,然后对所得的二叉树进行中序遍历输出结果即可。

*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct BTnode{
char data;
struct BTnode* pLchild;
struct BTnode* pRchild;
}BTNODE,*PBTNODE;

void CreateBTree(PBTNODE*);
void Intraverse(PBTNODE);

int main(int argc, const char * argv[]) {

PBTNODE T;
CreateBTree(T);
Intraverse(T);
return 0;

}
void CreateBTree(PBTNODE *t){
char ch;
scanf("%c",&ch);
if(ch=='#') t=NULL;

else{
        *t=(PBTNODE)malloc(sizeof(BTNODE));
        (*t)->data=ch;//生成根节点
    CreateBTree(&(*t)->pRchild);//生成左子树
    CreateBTree(&(*t)->pLchild);//生成右子树
       
    }

}
void Intraverse(PBTNODE t){
if(t==NULL) return;
Intraverse(t->pLchild);
printf("%c",t->data);
Intraverse(t->pRchild);
}

你题目的解答代码如下:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct BTnode
{
    char data;
    struct BTnode *pLchild;
    struct BTnode *pRchild;
} BTNODE, *PBTNODE;

void CreateBTree(PBTNODE *);
void Intraverse(PBTNODE);

int main(int argc, const char *argv[])
{
    PBTNODE T;
    CreateBTree(&T);  // CreateBTree() 形参是二级指针, T前加& 传T的地址
    Intraverse(T);
    return 0;
}
void CreateBTree(PBTNODE *t)
{
    char ch;
    scanf("%c", &ch);
    if (ch == '#')
        *t = NULL;  //  t前加 *
    else
    {
        *t = (PBTNODE)malloc(sizeof(BTNODE));
        (*t)->data = ch;             //生成根节点
        //先生成左子树再生成右子树
        CreateBTree(&(*t)->pLchild); //生成左子树
        CreateBTree(&(*t)->pRchild); //生成右子树
    }
}
void Intraverse(PBTNODE t)
{
    if (t == NULL)
        return;
    Intraverse(t->pLchild);
    printf("%c", t->data);
    Intraverse(t->pRchild);
}

img

如有帮助,望采纳!谢谢!