交换二叉树的左右孩子

typedef char TElemType;

typedef struct BiNode
{
TElemType data;
stuct BiNode *lchild,*rchild;
}BiNode,*BiTree;

tree create()
{
int x;
tree t;
scanf("%d",&t);
if(x==0) t=NULL;
else
{
t=(tnode *)malloc(sizeof(tnode));
t->data=x;
t->lchild=create();
t->rchild=create();
}
return t;
}

void Treeswap(tree t)
{
if(t)
{
tree p=t->lchild;
t->rchild=t->lchild;
t->lchild=p;
Treeswap(t->lchild);
Treeswap(t->rchild);
}
}

posted on 2016-10-29 21:53  Dove1  阅读(381)  评论(0编辑  收藏  举报