递归算法交换左右子树显示有错误,求大神指点
#include "stdio.h"#include "stdlib.h"
#define maxsize 8
typedef struct node{
char data;
struct node *lchild,*rchild;
}BiTree;
BiTree *CREATREE()
{
BiTree*Q[maxsize];
int front=0,rear=0;
char ch;
BiTree *s,*root=NULL;
while((ch=getchar())!='\n')
{
s=NULL;
if(ch!='#')
{
s=(BiTree *)malloc(sizeof(BiTree));
s->data=ch;
s->lchild=s->rchild=NULL;
}
Q[++rear]=s;
if(rear==1)
root=s;
else
{
if(Q[rear]&&Q[front])
if(!(rear%2))
Q[front]->lchild=s;
else
Q[front]->rchild=s;
}
if(rear%2==1) front++;
}
return root;
}
void SWAP(BiTree*t)
{
BiTree *temp = NULL;
temp=t->lchild;
t->lchild=t->rchild;
t->rchild=temp;
if(t->lchild)
SWAP(t->lchild);
if(t->rchild)
SWAP(t->rchild);
}
void main()
{
BiTree *T;
T=BiTree *CREATREE();
SWAP(T);
}
--------------------Configuration: SWAP - Win32 Debug--------------------
Compiling...
SWAP.CPP
e:\学习\microsoft visual studio\myprojects\swap交换左右子树\swap.cpp(56) : error C2275: 'BiTree' : illegal use of this type as an expression
e:\学习\microsoft visual studio\myprojects\swap交换左右子树\swap.cpp(7) : see declaration of 'BiTree'
执行 cl.exe 时出错.
SWAP.exe - 1 error(s), 0 warning(s)