//实验题目:已知二叉树以二叉链表作为存储结构,写一个算法来交换二叉树的所有节点的左右子树
//先建立二叉树的二叉链表存储结构,再完成算法,注意结果的输出形式
#include
#include
#include
#define STACK_INIT_SIZE 100;
#define STACKINCREMENT 10;
//定义二叉树数据类型
typedef char TElemtype;
typedef struct BiTNode
{
TElemtype data;
struct BiTNode *lchild,*rchild;
}BiTNode,*BiTree;
//-------二叉树基本操作-------
//初始化二叉树
bool InitBiTree(BiTree &T)
{
T=(BiTree)malloc(sizeof(BiTNode));
T->data=NULL;
T->lchild=NULL;
T->rchild=NULL;
return true;
}
//创建二叉树
void CreateBiTree(BiTree &T)
{
TElemtype c=' ';
c=getchar();
getchar();
if(c==' ')
{
T=NU