本文整理汇总了C++中Solution::Deserialize方法的典型用法代码示例。如果您正苦于以下问题:C++ Solution::Deserialize方法的具体用法?C++ Solution::Deserialize怎么用?C++ Solution::Deserialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Solution
的用法示例。
在下文中一共展示了Solution::Deserialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
TreeNode* root = new TreeNode(1);
root->right = new TreeNode(2);
root->right->left = new TreeNode(3);
Solution sl;
char* ans = sl.Serialize(root);
printf("%s\n", ans);
char* str = "100|^|200|300|^|^|^";
TreeNode* t = sl.Deserialize(str);
queue<TreeNode*> q;
q.push(t);
while (!q.empty()) {
TreeNode* temp = q.front(); q.pop();
if (temp == NULL) {
printf(" -1");
} else {
printf(" %d", temp->val);
q.push(temp->left);
q.push(temp->right);
}
}
return 0;
}
示例2: __tmain
int __tmain( )
{
TreeNode tree[7];
tree[0].val = 8;
tree[0].left = &tree[1];
tree[0].right = &tree[2];
tree[1].val = 6;
tree[1].left = &tree[3];
tree[1].right = &tree[4];
tree[2].val = 10;
tree[2].left = &tree[5];
tree[2].right = &tree[6];
tree[3].val = 5;
tree[3].left = NULL;
tree[3].right = NULL;
tree[4].val = 7;
tree[4].left = NULL;
tree[4].right = NULL;
tree[5].val = 9;
tree[5].left = NULL;
tree[5].right = NULL;
tree[6].val = 11;
tree[6].left = NULL;
tree[6].right = NULL;
Solution solu;
cout <<solu.Serialize(tree) <<endl;
cout <<solu.Serialize(solu.Deserialize(solu.Serialize(tree))) <<endl;
return 0;
}