怎么运行不了呢?
#include <stdio.h>#include <stdlib.h>
typedef char DataType;
typedef struct node{
DataType data;
struct node *lchild,*rchild;
}BinTNode;
typedef BinTNode *BinTree;
#define QueueSize 20
#define Error printf
typedef BinTree QDataType;
typedef struct{
int front;
int rear;
int count;
QDataType data[QueueSize];
}CirQueue;
int count;
void CreateBinTree(BinTree *T);
void Levelorder(BinTree T);
void InitQueue(CirQueue *Q);
void EnQueue(CirQueue *Q,QDataType x);
QDataType DeQueue(CirQueue *Q);
int QueueEmpty(CirQueue *Q);
int QueueFull(CirQueue *Q);
void main()
{BinTree T;
char ch1,ch2;
printf("欢迎进入二叉树层次遍历操作,请选择:\n");
ch1='y';
while(ch1=='y' || ch1=='Y')
{printf("\nA-------------------------二叉树建立");
printf("\nB-------------------------层次遍历");
printf("\nC-------------------------退出\n");
scanf("\n%c",&ch2);
switch(ch2)
{case 'A':
case 'a':printf("请按带空结点的二叉树的先序序列输入结点\n");
CreateBinTree(&T);break;
case 'B':
case 'b':Levelorder(T);break;
case 'C':
case 'c':ch1='n';break;
default:ch1='n';
}
}
}
void CreateBinTree(BinTree *T)
{char ch;
scanf("\n%c",&ch);
if (ch=='0') *T=NULL;
else {*T=(BinTNode*)malloc(sizeof(BinTNode));
(*T)->data=ch;
CreateBinTree(&(*T)->lchild);
CreateBinTree(&(*T)->rchild);
}
}
void Levelorder(BinTree T)
{CirQueue *Q;
BinTree p;
InitQueue(Q);
if (T) EnQueue(Q,T);
while(!QueueEmpty(Q))
{p=DeQueue(Q);
printf("%3c",p->data);
/*****************************************************/
if(p->lchild)
EnQueue(Q,p->lchild);
if(p->rchild)
EnQueue(Q,p->rchild);
/*****************************************************/
}
}
void InitQueue(CirQueue *Q)
{Q->front=Q->rear=0;
Q->count=0;
}
int QueueEmpty(CirQueue *Q)
{return Q->count==0;
}
int QueueFull(CirQueue *Q)
{return Q->count==QueueSize;
}
void EnQueue(CirQueue *Q, QDataType x)
{if (QueueFull(Q)) Error("Queue overflow");
/**********************************************/
else {Q->count++;
Q->data[Q->rear]=x;
Q->rear=(Q->rear+1)%QueueSize;
}
/*********************************************/
}
QDataType DeQueue(CirQueue *Q)
{QDataType temp=NULL;
if (QueueEmpty(Q)) Error("Queue underflow");
/************************************************/
else {temp=Q->data[Q->front];
Q->count--;
Q->front=(Q->front+1)%QueueSize;
}
/************************************************/
return temp;
}