文章
10
粉丝
0
获赞
5
访问
756
#include<iostream>
#include<string>
struct TreeNode {
char ch;
TreeNode* lchild;
TreeNode* rchild;
};
std::string s = "";
int length = 0;
void CreateTree(TreeNode*& root) {
if (length==s.size())
{
return;
}
char ch = s[length++];
if (ch == '#')
{
root = nullptr;
}
else {
root = new TreeNode();
root->ch = ch;
root->lchild = nullptr;
root->rchild = nullptr;
CreateTree(root->lchild);
CreateTree(root->rchild)...
登录后发布评论
暂无评论,来抢沙发