层序遍历(使用队列)建立二叉树,然后中序遍历输出。输入的vector按照满二叉树的位置填入元素,空的节点值为NULL。用于数据结构树的题目自己运行查看结果。
#include<iostream>
#include<vector>
#include<queue>
#define MaxNode 100
using namespace std;
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {
}
};
TreeNode* createBLink(vector<