二叉树的建树

#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);
}
}

转载于:https://www.cnblogs.com/woyaocheng/p/4948404.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值