[求助]有兴趣的帮我找错,谢谢啊
#include<stdio.h>
#include<stdlib.h>
#define MAXSIZE 100
typedef char DataType;
typedef struct bnode{
DataType data;
struct bnode *lchild,*rchild;
}Bnode,*BTree;
typedef struct{
DataType data[MAXSIZE];
int front,rear;
}SeqQueue,*PSeqQueue;
PSeqQueue Init_SeqQueue()
{
PSeqQueue Q=(PSeqQueue)malloc(sizeof(SeqQueue));
if(Q)
{
Q->front=0;
Q->rear=0;
}
return Q;
}
int Empty_SeqQueue(PSeqQueue Q)
{
if(Q&&Q->front==Q->rear)
return 1;
else
return 0;
}
int In_SeqQueue(PSeqQueue Q,DataType x)
{
if((Q->rear+1)%MAXSIZE==Q->front)
{
printf("dui man");
return -1;
}
else
{
Q->rear=(Q->rear+1)%MAXSIZE;
Q->data[Q->rear]=x;
return 1;
}
}
int Out_SeqQueue(PSeqQueue Q,DataType *x)
{
if(Empty_SeqQueue(Q))
{
printf("dui kong");
return -1;
}
else
{
Q->front=(Q->front+1)%MAXSIZE;
*x=Q->data[Q->front];
return 1;
}
}
BTree Create_Tree()
{
char ch,ch1,ch2;
BTree t,p,q;
PSeqQueue qs;
qs=Init_SeqQueue();
ch=getchar();
if(ch!='#')
{
p=(BTree)malloc(sizeof(Bnode));
p->data=ch;
in_SeqQueue(qs,p->data);
}
else return 0;
while(!Empty_SeqQueue(qs))
{
out_SeqQueue(qs,&t); /*这里我也弄不明白*/
ch1=getchar();
if(ch1!='#')
{
q=(BTree)malloc(sizeof(Bnode));
q->data=ch1;
t->lchild=q;
in_SeqQueue(qs,q->data);
}
else t->lchild=0;
ch2=getchar();
if(ch2!='#')
{
q=(BTree)malloc(sizeof(Bnode));
q->data=ch2;
t->rchild=q;
in_SeqQueue(qs,q->data);
}
else t->rchild=0;
}
return (p);
}
main()
{
BTree s;
printf("shu chu yi ge er cha shu ");
s=Create_Tree();
printf("%s",s);
}