树的创建和遍历,输出不了

树的创造和遍历,都是线序,输出不了,输完子树点个运行就这样了,两张图

img

img

可以用我这个

#include <stdio.h>
#include <stdlib.h>
typedef struct Binnode//结构定义
{

    char data;//数据域
    struct Binnode *lchild;//左孩子
    struct Binnode *rchild;//右孩子
}Binnode, *Bintree;

//创建二叉树
void Create_Bintree(Bintree *bt)
{

     char ch;
     if((ch = getchar()) == '#')
     {

        *bt = NULL;//空子树
     }
     else
     {

         *bt = (Binnode *)malloc(sizeof(Binnode));//开辟空间
         (*bt)->data = ch;
         Create_Bintree(&(*bt)->lchild);//创建左子树
         Create_Bintree(&(*bt)->rchild);//创建右子树
     }
}

//先序遍历
void Preorder(Bintree *bt)
{

   if (*bt != NULL)
   {

       printf("%c", ((*bt)->data));
       Preorder(&(*bt)->lchild);//先序遍历左子树
       Preorder(&(*bt)->rchild);//先序遍历右子树
   }
}
void main()
{

      Bintree T;
        printf("请输入一个二叉树:\n");
      Create_Bintree(&T);
        printf("Tree Create OK!\n");
        printf("先序遍历:\n");
      Preorder(&T);
        printf("\n");
 }


img