首页 > 其他 > 详细

二叉树的建树

时间:2015-11-08 22:10:52      阅读:254      评论:0      收藏:0      [点我收藏+]

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
char s[100000];
int flog=0;
struct tree
{
char a;
struct tree *left,*right;
}*head;
tree * great()
{
char k;
scanf("%c",&k);
tree *p1;
p1=(tree *)malloc(sizeof(tree));
if(k==‘#‘)
{
p1=NULL;
}
else
{
p1->a=k;
p1->left=great();
p1->right=great();
}
return p1;
}

void pre(tree *p1)
{
if(p1)
{
printf("%c",p1->a);
pre(p1->left);
pre(p1->right);
}
// else printf("#");
}

void zhong(tree *p1)
{
if(p1)
{

zhong(p1->left);
printf("%c",p1->a);
zhong(p1->right);
}

}

void fun(tree *p1)
{
if(p1)
{

fun(p1->left);

fun(p1->right);
printf("%c",p1->a);
}
}

二叉树的建树

原文:http://www.cnblogs.com/woyaocheng/p/4948404.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!