要求实现给定的二叉树的层次遍历

本题要求实现给定的二叉树的层次遍历。
函数接口定义:



void Levelorder(BiTree T);

T是二叉树树根指针,Levelorder函数输出给定二叉树的层次遍历序列,格式为一个空格跟
其中BinTree结构定义如下:

typedef char ElemType;
typedef struct BiTNode
{
   ElemType data;
   struct BiTNode *lchild, *rchild;
}BiTNode, *BiTree;
裁判测试程序样例:

#include <stdio.h>
#include <stdlib.h>

typedef char ElemType;
typedef struct BiTNode
{
   ElemType data;
   struct BiTNode *lchild, *rchild;
}BiTNode, *BiTree;

BiTree Create();/* 细节在此不表 */

void Levelorder(BiTree T);

int main()
{
   BiTree T = Create();
   printf("Levelorder:"); Levelorder(T); printf("\n");
   return 0;
}
/* 你的代码将被嵌在这里 */


输入样例:
输入为由字母和'#'组成的字符串,代表二叉树的扩展先序序列。例如对于如下二叉树,输入数据:
AB#DF##G##C##



望采纳!谢谢

void levelorder(BiTree T){
    InitQueue(Q);
    BiTree p;
    EnQueue(Q,T);
    while(!IsEmpty(Q)){
        DeQueue(Q,p);
        visit(p);
        if(p->left!=NULL)
            EnQueue(Q,p->left);
        if(p->right!=NULL)
            EnQueue(Q,p->right);
    }
    
}