📄 emp5_16.cpp
字号:
// emp5_16
#include "btrechar.h"
bptrlink ptr;
int n,n1;
void nodes1(bitre t)
{
int n1;
if (t==NULL) n=0;
else{
nodes1(t->lchild);
n1=n;
nodes1(t->rchild);
n=n+1+n1;
bptr_point_to(ptr, t);
getch();
dispint_atbnode_angle(n,t,0);
}
}
void nodes2(bitre t)
{
if (t==NULL) n=0; //{ Wrong }
else{
nodes2(t->lchild);
n1=n;
n=n+1+n1;
bptr_point_to(ptr, t);
getch();
dispint_atbnode_angle(n,t,0);
nodes2(t->rchild);
}
}
void nodes3(bitre t)
{
if (t==NULL) ; //n=0; //{ Correct }
else{
nodes3(t->lchild);
n=n+1;
bptr_point_to(ptr,t);
getch();
dispint_atbnode_angle(n,t,0);
nodes3(t->rchild);
}
}
void main()
{
bitre t;
int k;
initial_bitre();
load_bitre_file(t,"bitres\\full42.cbt");
comput_bitre_card(t);
window(1,1,80,4);
create_bptr(ptr, "T");
disp_bitre("Preorder",t);
n=0;
nodes1(t);
printf("nodes1=%d\n",n);
disp_bitre("Preorder",t);
n=0;
nodes2(t);
printf("nodes2=%d\n",n);
disp_bitre("Preorder",t);
n=0;
nodes3(t);
printf("nodes3=%d\n",n);
getch();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -