#include
struct Bitree
{
char c;
struct Bitree *l;
struct Bitree *r;
};
struct Bitree * create(){
char ch;
struct Bitree *s;
scanf("%c",&ch);
if(ch=='#')
return NULL;
else
{
s=(struct Bitree *)malloc(sizeof(struct Bitree));
s->c=ch;
s->l=create();
s->r=create();
return s;
}
}
void preorder(struct Bitree *root)
{
if(root!=NULL)
{
printf("%c",root->c);
preorder(root->l);
preorder(root->r);
}
}
void inorder(struct Bitree *root)
{
if(root!=NULL)
{
inorder(root->l);
printf("%c",root->c);
inorder(root->r);
}
}
void lastorder(struct Bitree *root)
{
if(root!=NULL)
{
lastorder(root->l);
lastorder(root->r);
printf("%c",root->c);
}
}
遍历不会还是整个都不会?