有人知道为什么会这样吗

#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAXLEN 100
#define NLAYER 4
typedef struct BiTNode
{
char data;
struct BiTNode *LChild,*RChild;
}BiTNode,*BiTree;
BiTree T;
void CreateBiTree(BiTree *bt)
{
char ch;
scanf("%c",&ch);
if(ch=='#') *bt=NULL;
else
{
*bt=(BiTree)malloc(sizeof(BiTNode));
(*bt)->data=ch;
CreateBiTree(&((*bt)->LChild));
CreateBiTree(&((*bt)->RChild));
}
}
void TranslevelPrint(BiTree bt)
{
struct node
{
BiTree vec[MAXLEN];
int layer[MAXLEN];
int locate[MAXLEN];
int front,rear;
}q;
int i,j=1,k=0,nLocate;
q.front=0;q.rear=0;
printf(" ");
q.vec[q.rear]=bt;
q.layer[q.rear]=1;
q.locate[q.rear]=(int)(12+pow(2,NLAYER-1));
q.rear=q.rear+1;
while(q.front<q.rear)
{
bt=q.vec[q.front];
i=q.layer[q.front];
nLocate=q.locate[q.front];
if(j<i)
{
printf("\n");printf("\n");
j=j+1;k=0;
while(k<nLocate)
{
printf(" ");k++;
}
}
while(k<(nLocate-1))
{
printf(" ");k++;
}
printf("%c",bt->data);
q.front=q.front+1;
if(bt->LChild !=NULL)
{
q.vec[q.rear]=bt->LChild;
q.layer[q.rear]=i+1;
q.locate[q.rear]=(int)(nLocate-pow(2,NLAYER-i));
q.rear=q.rear+1;
}
if(bt->RChild !=NULL)
{
q.vec[q.rear]=bt->RChild;
q.layer[q.rear]=i+1;
q.locate[q.rear]=(int)(nLocate+pow(2,NLAYER-i));
q.rear=q.rear+1;
}
}
}
void Visit(char ch)
{
printf("%c ",ch);
}
void PreOrder(BiTree root)
{
if(root!=NULL)
{
Visit(root->data);
PreOrder(root->LChild);
PreOrder(root->RChild);
}
}
void InOrder(BiTree root)
{
if(root!=NULL)
{
InOrder(root->LChild);
Visit(root->data);
InOrder(root->RChild);
}
}
void PostOrder(BiTree root)
{
if(root!=NULL)
{
PostOrder(root->LChild);
PostOrder(root->RChild);
Visit(root->data);
}
}
void PreorderLeaf(BiTree root)
{
if(root!=NULL)
{
if(root->LChild==NULL&&root->RChild==NULL)
print("%c ",root->data);
PreOrderLeaf(root->LChild);
PreOrderLeaf(root->RChild);
}
}
int LeafCount(BiTree root)
{
int hl,hr,max;
if(root!=NULL)
{
hl=PostTreeDepth(root->LChild);
hr=PostTreeDepth(root->RChild);
max=hl>hr?hl:hr;
return(max+1);
}
else return(0);
}
void mainwork()
{
int yourchoice;
printf("\n-----------------欢迎使用二叉树基本操作程序----------\n");
printf("\n 菜单选择 \n\n");
printf(" 1.树状输出二叉树 2.先序遍历二叉树 \n");
printf(" 3.中序遍历二叉树 4.后序遍历二叉树 \n");
printf(" 5.输出叶子结点 6.输出叶子结点个数 \n");
printf(" 7.输出二叉树的深度 8.退出 \n");
printf("\n-----------------------------------------------------\n");
scanf("请输入您的选择:");
scanf("%d",&yourchoice);
while(!(yourchoice==1||yourchoice==2||yourchoice==3||yourchoice==4||yourchoice==5||yourchoice==6||yourchoice==7||yourchoice==8))
{
printf("输入选择不明确,请重输\n");
scanf("%d",&yourchoice);
}
while(1)
{ switch(yourchoice)
{
case 1:printf("树的形状为:\n");Translevelprint(T);getch();break;
case 2:printf("先序遍历序列为:");PreOrder(T);break;
case 3:printf("\n 中序遍历序列为:");InOrder(T);break;
case 4:printf("\n 后序遍历序列为:");PostOrder(T);break;
case 5:printf("叶子结点为:");PreOrderLeaf(T);break;
case 6:printf("叶子结点为:%d",LeafCount(T));break;
case 7:printf("二叉树的深度为:%d",PostTreeDepth(T));break;
case 8:system("cls");exit(0);break;
default:break;
}
printf("\n-----------------欢迎使用二叉树基本操作程序----------\n");
printf("\n 菜单选择 \n\n");
printf(" 1.树状输出二叉树 2.先序遍历二叉树 \n");
printf(" 3.中序遍历二叉树 4.后序遍历二叉树 \n");
printf(" 5.输出叶子结点 6.输出叶子结点个数 \n");
printf(" 7.输出二叉树的深度 8.退出 \n");
printf("\n-----------------------------------------------------\n");
scanf("请输入您的选择:");
scanf("%d",&yourchoice);
}
}
void main()
{
printf("首先请输入二叉树的结点序列:\n");
CreateBiTree(&T);
printf("请按菜单提示操作:\n");
mainwork();
}

img

img

是不是运行过没有关闭之前运行的窗口

https://blog.csdn.net/songyu0120/article/details/46931329/