#include
#include
#include
using namespace std;
/*** 题目:给一个满二叉树的前序遍历,求该二叉树的 中序遍历。
*/
struct Node{int value;Node *left,*right;Node(int val,Node* l,Node* r):value(val),left(l),right(r){}
};Node* createTree(vector& nums,int& pos,int h,int height){int l=nums.size();// if(pos==l || h==height) return nullptr;Node* root=new Node(nums[pos],nullptr,nullptr);if(pos+1left=createTree(nums,pos,h,height);h--;}if(pos+1right=createTree(nums,pos,h,height);h--;}return root;
}void pr(Node* root){if(root==nullptr)return;pr(root->left);cout<value<<" ";pr(root->right);
}int main(){vector nums={1,2,3,4,5,6,7};int k=0;Node* root=createTree(nums,k,1,3);pr(root);return 0;
}