计算以孩子-兄弟链表示的树的高度
											利用递归的方法计算树高,但是运行结果总是2,是不是在创建的时候出了问题?
程序代码:#include <stdio.h>
#include <stdlib.h>
typedef char telemtype;
typedef struct tnode{
    telemtype data;
    struct tnode *hp,*vp;}tnode,*bitree;
int visit(bitree p){
    int max=0;
    if(p!=NULL){
        printf("%c ",p->data);
        visit(p->hp);
        visit(p->vp);
    }
    return max;
}
void createbt(bitree &bt){
    char ch;
    scanf("%c",&ch);
    if(ch=='#')bt=NULL;
    else{
        bt=(bitree)malloc(sizeof(tnode));
        bt->data=ch;
        createbt(bt->hp);
        createbt(bt->vp);
    }
}
int height(bitree &bt){
    tnode *p;
    int m,max=0;
    if(bt==NULL)
        return 0;
    else if(bt->vp==NULL)
        return 1;
    else{
        p=bt->vp;
        while(p!=NULL){
            m=height(p);
            if(max<m) max=m;
            p=p->hp;
        }
        return m+1;
    }
}
void main(){
    bitree bt;
    printf("请输入树:");
    createbt(bt);
    printf("树为:\n");
    visit(bt);
    printf("\n树深为%d\n",visit(bt));
}
										
					
	


											
	    

	
											



