#include
#include
using namespace std;
typedef struct BitNode{
char data;
struct BitNode *lc,*rc;
}BitNode,*BitTree;
void CreateBitTree(BitTree &T){
char ch; cin >> ch;
if(ch=='#')
T = NULL;
else{
T = (BitTree)malloc(sizeof(BitNode));
T->data = ch;
CreateBitTree(T->lc);
CreateBitTree(T->rc);
}
}
void VisitBitTree(BitTree T){
if(T!=NULL){
VisitBitTree(T->lc);
cout << T->data;
VisitBitTree(T->rc);
}
}
int main(){
BitTree T = NULL;
T = (BitTree)malloc(sizeof(BitNode));
CreateBitTree(T);
VisitBitTree(T);
return 0;
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)