#include<stdio.h>
#include<stdlib.h>
#define NULL 0
#define OK 1
#define ERROR -1
int n=0;
typedef struct Bnode
{
char data;
struct Bnode *lchild,*rchild;
}Bnode;
Bnode *CreateTree(Bnode *T)
{
char ch;
printf("input root:\n");
scanf("%c",&ch);
getchar();
if(ch==' ')
T=NULL;
else
{
T=(Bnode *)malloc(sizeof(Bnode));
T->data=ch;
T->lchild=CreateTree(T->lchild);
printf("input rchild:\n");
T->rchild=CreateTree(T->rchild);
}
return T;
}
int PrintTree(Bnode *T)
{ if(T)
{
printf("%c",T->data);
PrintTree(T->lchild);
PrintTree(T->rchild);
return OK;
}
else
return ERROR;
}
void main()
{
Bnode *T;
T=CreateTree(T);
PrintTree(T);
}