二叉树的宽度即具有结点数最多的那一层结点数的个数
/* 思路:得到每一层的结点个数,进行比较,最大的即为宽度 */
typedef struct{ //顺序非循环队列的队列元素结构体
BTNode *p;
int lon;
}St;
int maxNode(BTNode *b){
St que[maxSize]; //定义顺序非循环队列
int front=0,front=0;
int Lno=0;
BTNode *q;
if(b!=Null){
++rear; //树根入队,并将其层次设置为 1
que[rear].p=b;
que[rear].lon=1;
while(front!=rear){
++front; //出队
q=que[front].p;
Lno=que[front].lno;
if(q->lchild!=NULL){
++rear;
que[rear].p=q->lchild;
que[rear].lon=Lon+1;
}
if(q->rchild!=NULL){
++rear;
que[rear].p=q->rchild;
que[rear].lon=Lon+1;
}
}
int max=0;
for(int i=1;i<=Lon;i++){
int n=0;
for(j=0;j,rear;j++)
if(que[j].lon==i)
++n;
if(max<n)
max=n;
}
return max;
}
else return 0;
}