本题要求实现按从左到右顺序打印二叉树的指定层次的结点序列。
函数接口定义:
void PrintLevel(BiTree T,int n);
T是二叉树树根指针,n为指定打印的层次,PrintLevel函数按从左到右顺序输出二叉树的指定层次的结点序列,格式为一个字符后面跟着一个空格。
其中BinTree结构定义如下:
typedef char ElementType;
typedef struct BiTNode {
ElementType data;
struct BiTNode *lchild;
struct BiTNode *rchild;
}BiTNode, *BiTree;
裁判测试程序样例:
#include <stdio.h>
#include <stdlib.h>
typedef char ElementType;
typedef struct BiTNode {
ElementType data;
struct BiTNode *lchild;
struct BiTNode *rchild;
}BiTNode, *BiTree;
BiTree Create();/* 细节在此不表 */
void PrintLevel(BiTree T, int n);
int main()
{
int n;
BiTree T = Create();
scanf("%d", &n);
PrintLevel(T, n);
printf("\n");
return 0;
}
/* 你的代码将被嵌在这里 */