[题目分析] 计算每层中结点值大于的结点个数应按层次遍历设一队列Q用front和rear分别指向队头和队尾元素last指向各层最右结点的位置存放值大于的结点结构为
typedef struct {int levelvalueidx; }node;//元素所在层号值和本层中的序号
node a[]s;
void ValueGT(BiTree bt)//查各层中结点值大于的结点个数输出其值及序号
{if(bt!=null)
{int front=last=rear=level=i=num=;//num记>的结点个数
BiTree Q[];Q[]=bt;//根结点入队
while(front<=last)
{bt=Q[++front];
if(bt>data>){slevel=level; sidx=++i; svalue=bt>data; a[++num]=s;}
if(bt>lchild!=null) Q[++rear]=bt>lchild;//左子女入队列
if(bt>rchild!=null) Q[++rear]=bt>rchild;//右子女入队列
if(front==last) {last=rear; level++; i=;} //本层最后一个结点已处理完
} //初始化下层last指向下层最右结点层号加下层>的序号初始为
}//while
for(i=;i<=num;i++) //输出data域数值大于的结点的层号data域的数值和序号
printf(层号=%d本层序号=%d值=%da[i]levela[i]idxa[i]value);
}//算法ValueGT结束
[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []