二叉树层次遍历改错
#include<stdio.h>#include<stdlib.h>
#define ERROR 0
#define OVERFLOW -1
#define OK 1
#define NULL 0
#define maxqsize 10
typedef char elemtype
typedef struct bitree
{
bitree *lchild;
bitree *rchild;
elemtype data;
}bitree;
typedef struct queue
{
int front,rear;
bitree *base;
}queue;
int inittree(queue *Q);
int leverordertraverse(bitree *t);
int creatbitree(bitree *t);
int enterbitree(queue *Q,bitree *p);
int printfbitree(bitree *p);
void main()
{
creatbitree(t);
leverordertraverse(t);
}
int creatbitree(bitree *t)
{ elemtype ch;
scanf("%c",&ch);
if(ch==' ')
t=NULL;
else
{
if(!(bitree *)malloc(sizeof(bitree))))
exit(OVERFLOW);
t->data=ch;
creatbitree(t->lchild);
creatbitree(t->rchild);
}
return OK;
}
int initqueue(queue *Q)
{
Q->front=Q->rear=(int *)malloc(sizeof(bitree);
if(!Q->front)
exit(OVERFLOW);
Q->front=Q->rear;
return OK;
}
int enterqueue(queue *Q,bitree *p)
{
if((Q->rear+1)%maxqsize==Q->front)
return ERROR;
Q->base[Q->rear]=p->data;
Q->rear=(Q->rear+1)%maxqsize;
return OK;
}
int leverordertraverse(bitree *t)
{ queue *Q;
bitree *p=t;
initqueue(Q);
enterqueue(Q,p);
if(p!=NULL)
EnterQueue(Q,p);
while(!queueempty(Q))
{
depueue(Q,p);
printf("%c",p->data);
if(p->lchild)
enterqueue(Q,p->lchild);
if(p->rchild)
enterpueue(Q,p->rchild);
}
return OK;
}
--------------------Configuration: 二叉树 - Win32 Debug--------------------
Compiling...
1.cpp
D:\VC\MyProjects\二叉树\1.cpp(10) : error C2143: syntax error : missing ';' before '<class-head>'
D:\VC\MyProjects\二叉树\1.cpp(10) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.
二叉树.exe - 1 error(s), 0 warning(s)
新手不懂到底怎么改,望大虾指教啊