建立一个二叉树

上传人:碎****木 文档编号:220861447 上传时间:2021-12-09 格式:DOCX 页数:2 大小:27.82KB
返回 下载 相关 举报
建立一个二叉树_第1页
第1页 / 共2页
建立一个二叉树_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

《建立一个二叉树》由会员分享,可在线阅读,更多相关《建立一个二叉树(2页珍藏版)》请在金锄头文库上搜索。

1、建立一个二叉树 程序: #include #include #include typedef struct nodechar data;struct node *lchild; struct node *rchild;BTNode;BTNode *CreateTree(BTNode *L,char str100); void DispLeaf(BTNode *L);int i=0; void main()BTNode *L;char str100;L=(BTNode *)malloc(sizeof(BTNode); scanf(“%s“,str);L=CreateTree(L,str);Dis

2、pLeaf(L);BTNode *CreateTree(BTNode *L,char str100)BTNode *k=NULL; if(stri=”0”) L=NULL;else L=(BTNode *)malloc(sizeof(BTNode);L-data=stri;L-lchild=L-rchild=NULL;i+; L-lchild=CreateTree(k,str); i+; L-rchild=CreateTree(k,str);return(L);void DispLeaf(BTNode *L)if(L!=NULL)if(L-lchild=NULL&L-rchild=NULL) printf(“%c“,L-data);elseprintf(“%c“, L-data);DispLeaf(L-lchild);DispLeaf(L-rchild);调试程序程序结果

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 行业资料 > 教育/培训

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号