#include<stdio.h>#include<malloc.h>typedef?struct?BTNode{
?????int?data;
?????struct?BTNode?*Lchild,*Rchild;
}BiTnode,*Btree;
//遞歸算法創(chuàng)建二叉樹
void?CreatBTree(Btree?tr){
????int?ch;
????scanf("%d",&ch);
????if(ch==0)
????tr=NULL;
????else{
????????tr=(Btree)malloc(sizeof(BiTnode));
????????tr->data=ch;
????????CreatBTree(tr->Lchild);
????????CreatBtree(tr->Rchild);
????}
}
int?main(){
????Btree?bt=NULL;
????CreatBtree(bt);
return?0;
}
void?CreatBtree(Btree?tr)這句話怎么修改能使傳過去的bt??再返回來創(chuàng)建好的樹?
二叉樹遞歸創(chuàng)建
慕碼人1088981
2016-12-04 22:54:58