剑指offer-序列化二叉树

2016/05/24 C和C++基础

题目描述

请实现两个函数,分别用来序列化和反序列化二叉树

#include <iostream>
#include <vector>
using namespace std; 
struct TreeNode {
    int val;
    struct TreeNode *left;
    struct TreeNode *right;
    TreeNode(int x):val(x),left(NULL),right(NULL){}
};
char* Serialize(TreeNode *root){    
	
}
int main(){
	TreeNode n1(1),n2(2),n3(3),n4(4),n5(5),n6(6);
	TreeNode *root=&n1;
	n1.left=&n2;
	n1.right=&n3;
	n2.left=&n4;
	n2.right=&n5;
	n3.right=&n6;
	system("pause");
}

Search

    Post Directory