📄 emp6_10.cpp
字号:
// emp6_10}
#include "trees.h"
tptrlink ptr;
int high(tree t)
{
int h,hight;
tree t1;
if (t==NULL) hight=0;
else{
t1=t->firstson;
h=0;
while (t1!=NULL){
h=Max(h, high(t1));
t1=t1->nextbrother;
}
hight=h+1;
tptr_point_to(ptr, t);
dispint_attnode_angle(h+1,t,150);
getch();
}
return hight;
}
int leaf(tree t)
{
int l,leaft;
tree t1;
if (t==NULL) leaft=0;
else{
if (t->firstson==NULL) l=1;
else{
l=0;
t1=t->firstson;
while (t1!=NULL){
l=l+leaf(t1);
t1=t1->nextbrother;
}
}
leaft=l;
tptr_point_to(ptr, t);
dispint_attnode_angle(l,t,270);
getch();
}
return leaft;
}
void main()
{
tree t;
int k;
get_tree(t);
create_tptr(ptr, "T");
printf("high=%d\n",high(t));
getch();
printf("leaf=%d\n",leaf(t));
getch();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -