主题:看看我的程序到底怎么回事?关于二叉树建立
#include"stdio.h"
#include"stdlib.h"
#define Null 0
typedef struct binode
{struct binode *lchild,*rchild;
char data;
} bitree;
int creatbitree(bitree *T)
{char ch;
scanf("%c",&ch);
if(ch==' ') T=Null;
else {
T=(bitree *)malloc(sizeof(bitree));
T->data=ch;
creatbitree(T->lchild);
creatbitree( T->rchild);
}
}
void preordertravel(bitree *T)
{if(T)
{ printf("%c",T->data);
preordertravel(T->lchild);
preordertravel(T->rchild);
}
}
void main()
{bitree *T;
creatbitree(T);
preordertravel(T);
getch();
}
#include"stdlib.h"
#define Null 0
typedef struct binode
{struct binode *lchild,*rchild;
char data;
} bitree;
int creatbitree(bitree *T)
{char ch;
scanf("%c",&ch);
if(ch==' ') T=Null;
else {
T=(bitree *)malloc(sizeof(bitree));
T->data=ch;
creatbitree(T->lchild);
creatbitree( T->rchild);
}
}
void preordertravel(bitree *T)
{if(T)
{ printf("%c",T->data);
preordertravel(T->lchild);
preordertravel(T->rchild);
}
}
void main()
{bitree *T;
creatbitree(T);
preordertravel(T);
getch();
}