二叉树建立的基本思路
来源:互联网 发布:heatmap制作软件 编辑:程序博客网 时间:2024/06/06 06:47
#include<stdio.h>
#include<stdlib.h>
typedef struct node //建立结点
{
char data;
struct node *lchild,*rchild; //左右孩子
}lnode,*binode;
binode creat() //建立结点的数据
{
binode p;
char ch;
scanf("%c",&ch);
if(ch=='*') //当读入的数据为* 时结束
{
p=NULL;
}
else
{p=(binode)malloc(sizeof(node));
p->data=ch;
p->lchild=creat(); //为右孩子赋值
p->rchild=creat();
}
return p; //返回,注意这时候的p为第一次的p
}
void print(binode n) //按照中序遍历输出,可调换 下列顺序变为前序,后序
{
if(n)
{print(n->lchild);
printf("%c",n->data);
print(n->rchild);
}
}
void main()
{
binode b;
b=creat();
print(b);
}
- 二叉树建立的基本思路
- 二叉树的建立
- 二叉树的建立
- 二叉树的建立
- 二叉树的建立
- 二叉树的建立
- 二叉树的建立
- 二叉树的建立
- 二叉树的建立
- 二叉树的建立
- 【二叉树的建立】
- 二叉树的建立
- 二叉树的建立
- 二叉树的建立
- 二叉树的建立
- 二叉树的建立
- 二叉树的建立
- 二叉树的建立
- 《宝岛双雄》曝正式海报 房祖名挑大梁的银幕转型之作
- 静下心来,专心学好Java各方面知识
- 数据库查询优化技术
- 娄烨表示《浮城谜事》是一部社会写实电影
- 内存分析
- 二叉树建立的基本思路
- 如何让你的SQL运行得更快
- Spring学习笔记 Hello World
- android TraceView 使用方法搜集
- 利用AssemblyResolve事件加载任意位置的程序集
- HDU3732 "假的01背包"
- 黑马程序员---Java基础--02天
- WKID与WKT含义
- C++中的作用域解析运算符::