资源预览内容
第1页 / 共2页
第2页 / 共2页
亲,该文档总共2页全部预览完了,如果喜欢就下载吧!
资源描述
#include “stdio.h“ #include “malloc.h“ #define maxsize 10 typedef struct node char data;struct node *lchild,*rchild; Bitree; Bitree *Qmaxsize; Bitree *create() char ch;int front,rear;Bitree *T,*s;T=NULL;front=1;rear=0;printf(“建立二叉树n“);ch=getchar();while(ch!=#)s=NULL;if(ch!=)s=(Bitree *)malloc(sizeof(Bitree);s-data=ch;s-lchild=s-rchild=NULL;rear+;Qrear=s;if(rear=1)T=s;else if(s!=NULLelse Qfront-rchild=s;if(rear%2=1)front+;ch=getchar();return T; void visite(Bitree *T) printf(“%cn“,T-data); int countleaf(Bitree *T) if(T=NULL) return 0; else if(T-lchild=NULL) else return (countleaf(T-lchild)+countleaf(T-rchild); main() Bitree *T; T=create(); printf(“叶子结点数%dn“,countleaf(T);
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号