#include<bits/stdc++.h>
typedef struct node
{
char data;
struct node *lchild,*rchild;
}BTNode;
void Greate(BTNode *&T)
{
char ch;
scanf("%c",&ch);
if(ch=='#') T=NULL;
else
{
T=(BTNode*)malloc(sizeof(BTNode));
T->data=ch;
Greate(T->lchild);
Greate(T->rchild);
}
}
void Disp(BTNode *T)
{
if(T!=NULL)
{
printf("%c",T->data);
if(T->lchild!=NULL || T->rchild!=NULL)
{
Disp(T->lchild);
if(T->rchild!=NULL) Disp(T->rchild);
}
}
}
int Level(BTNode *T,char x,int h)
{
int l;
if(T==NULL) return (0);
else if(T->data==x) return (h);
else
{
l=Level(T->lchild,x,h+1);
if(l!=0) return (1);
else return (Level(T->rchild,x,h+1));
}
}
int main()
{
BTNode *T;
Greate(T);
Disp(T);
int h;
char ch='A';
h=Level(T,ch,1);
if(h==0) printf("不存在此节点");
else printf("%c节点的层次为%d",ch,h);
return 0;
}