首页 > 代码库 > 二叉树的映象

二叉树的映象


很自然想起来递归:

代码:

#include <iostream>
#include <list>
using namespace std;

typedef struct tree1{
	int data;
	struct tree1 * lchild;
	struct tree1 * rchild;
}Tree,* pTree;

void createTree(pTree & p){
	int temp ;
	scanf("%d",&temp);
	if(temp != 0){
		p=(pTree)malloc(sizeof(Tree));
		p->data = http://www.mamicode.com/temp;>
运行结果: