📄 emp5_17.cpp
字号:
// emp5_17 traceeg4
#include "btrechar.h"
bptrlink ptr;
int h;
void high1t(bitre t,int &h)
{
int h1,h2;
if (t!=NULL){
h=h+1;
h1=h;
h2=h;
bptr_point_to(ptr, t);
getch();
dispint_atbnode_angle(h,t,180);
high1t(t->lchild,h1);
high1t(t->rchild,h2);
h=Max(h1,h2);
bptr_point_to(ptr, t); getch();
dispint_atbnode_angle(h,t,0);
}
}
void high2(bitre t,int &h)
{
int h1,h2;
if (t==NULL) h=0;
else{
high2(t->lchild,h1);
high2(t->rchild,h2);
h=Max(h1,h2)+1;
bptr_point_to(ptr, t);
getch();
dispint_atbnode_angle(h,t,0);
}
}
void high3(bitre t,int &h)
{
int h0;
if (t!=NULL){
h=h+1;
h0=h;
bptr_point_to(ptr, t);
getch();
dispint_atbnode_angle(h,t,180);
high3(t->lchild,h);
high3(t->rchild,h0);
h=Max(h,h0);
bptr_point_to(ptr, t);
getch();
dispint_atbnode_angle(h,t,0);
}
}
void high4(bitre t)
{
int h0;
if (t!=NULL){
bptr_point_to(ptr, t);
dispint_atbnode_angle(h,t,180);
getch();
high4(t->lchild);
h0=h;
high4(t->rchild);
h=Max(h,h0)+1;
bptr_point_to(ptr, t);
dispint_atbnode_angle(h,t,0);
getch();
}
}
void high5(bitre t)
{
int h1,h2;
if (t!=NULL){
h1=h+1;
h=0;
bptr_point_to(ptr, t);
getch();
dispint_atbnode_angle(h,t,180);
high5(t->lchild);
h2=h;
h=0;
high5(t->rchild);
h=h1+Max(h2,h);
bptr_point_to(ptr, t);
getch();
dispint_atbnode_angle(h,t,0);
}
}
void main()
{
bitre t;
get_bitre(t);
create_bptr(ptr, "T");
window(1,1,15,3);
disp_bitre("High1",t); //Disp for 1st High
h=0;
high1t(t,h);
printf("high1=%d\n",h);
getch();
disp_bitre("High2",t); //Disp for 2nd High
h=0;
high2(t,h);
printf("high2=%d\n",h);
getch();
disp_bitre("High3",t); //Disp for 3th High
h=0;
high3(t,h);
printf("high3=%d\n",h);
getch();
disp_bitre("High4",t); //Disp for 4th High
h=0;
high4(t);
printf("high4=%d\n",h);
getch();
disp_bitre("High5",t); //Disp for 5th High
h=0;
high5(t);
printf("high5=%d\n",h);
getch();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -