文章
2
粉丝
326
获赞
0
访问
22.6k
#include <iostream>
#include <string>
#include <vector>
using namespace std;
struct ListNode{
char val;
ListNode* left;
ListNode* right;
ListNode(char ch) : val(ch), left(NULL), right(NULL){}
};
void makeTree(string str, int& pos, ListNode* root)
{
if (pos >= str.size() || !root)
{
return;
}
if (str[++pos] != '#')
root->left = new ListNode(str[pos]);
makeTree(str, pos, root->left);
if (str[++pos] != '#')
root->right = new ListNode(str[pos]);
makeTree(str, pos, root->right);
}
void MidTraverse(ListNode* root, string& str)
{
if (root == NULL)
return...
登录后发布评论
暂无评论,来抢沙发