#include "stdio.h"
#include "stdlib.h"
typedef struct node
{
char data;
struct node *lchild,*rchild;
}bitree;
bitree *root;
bitree *create_preorder()
{
bitree *t;
char x;
x=getchar();
getchar();
if(x== '\n') t=NULL;
else
{
t=(struct node *)malloc(sizeof(bitree));
t->data=x;
t->lchild=create_preorder();
t->rchild=create_preorder();
}
return(t);
}
void preorder(bitree *t)
{
if(t!=NULL)
{
printf("data is %c\n",t->data);
preorder(t->lchild);
preorder(t->rchild);
free(t);
}
}
int main()
{
bitree *bintree;
bintree=create_preorder();
preorder(bintree);
}
转载于:https://blog.51cto.com/biott/1143731