#include<iostream>
#include<sstream>
#include<stdio.h>
#include<string>
#include<string.h>
#include<math.h>
#include<time.h>
#define LEN 1000
#define INF 99999
using namespace std; struct node{
string data;
node *left;
node *right;
};
typedef node *BiTree;//定义新类型 看成结点!! void createtree(BiTree *t)//传递给我结点的指针t
{
string s; cin>>s; if(s=="#")
{
(*t)=NULL; // 既然t是结点的指针 // (*t)就是对应结点 下面同样如此
return;
} (*t)=new node; (*t)->data=s;
createtree(&(*t)->left);
createtree(&(*t)->right);
} void lastvisit(BiTree t)//后序遍历不用解释
{
if(t==NULL) return; lastvisit(t->right);
lastvisit(t->left);
cout<<t->data<<endl;
} int main()
{
BiTree T;
createtree(&T);//主意这里容易出错 &T//由于函数的原理,只有传递指针类型才能对树进行创立
lastvisit(T); return 0;
}

  

标准建立二叉树NEW的更多相关文章

  1. [LeetCode] Construct Binary Tree from Preorder and Inorder Traversal 由先序和中序遍历建立二叉树

    Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that ...

  2. LeetCode 105. Construct Binary Tree from Preorder and Inorder Traversal (用先序和中序树遍历来建立二叉树)

    Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that ...

  3. LeetCode 106. Construct Binary Tree from Inorder and Postorder Traversal 由中序和后序遍历建立二叉树 C++

    Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that ...

  4. 【IT笔试面试题整理】给定二叉树先序中序,建立二叉树的递归算法

    [试题描述]:  给定二叉树先序中序,建立二叉树的递归算法 其先序序列的第一个元素为根节点,接下来即为其左子树先序遍历序列,紧跟着是右子树先序遍历序列,固根节点已可从先序序列中分离.在中序序列中找到 ...

  5. 数据结构实习 - problem K 用前序中序建立二叉树并以层序遍历和后序遍历输出

    用前序中序建立二叉树并以层序遍历和后序遍历输出 writer:pprp 实现过程主要是通过递归,进行分解得到结果 代码如下: #include <iostream> #include &l ...

  6. Pre- and Post-order Traversals(先序+后序序列,建立二叉树)

    PAT甲级1119,我先在CSDN上面发布的这篇文章:https://blog.csdn.net/weixin_44385565/article/details/89737224 Suppose th ...

  7. 数据结构之二叉树篇卷一 -- 建立二叉树(With Java)

    一.定义二叉树节点类 package tree; public class Node<E> { public E data; public Node<E> lnode; pub ...

  8. [LeetCode] 105. Construct Binary Tree from Preorder and Inorder Traversal 由先序和中序遍历建立二叉树

    Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that ...

  9. [LeetCode] 106. Construct Binary Tree from Inorder and Postorder Traversal 由中序和后序遍历建立二叉树

    Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that ...

随机推荐

  1. 第001篇——C#学习计划开启

    大年三十了,选在今天开启Blog,就是为了克服拖延症! Windows桌面程序,多年的执念,到现在一直不会写,再拖拉谁知道又要拖几年? 特此立下目标: 基本掌握C# winform 半年内可以做出一些 ...

  2. Android Studio无法关联Api23源码-提示Souces for android api 23 platform not found

    最近升级了As,然后忽然就关联不上源码了,很不方便,找个Activity的源码都只有outline没有解释,还提示这个错误: Decompiled .class file, bytecode vers ...

  3. css画图形

    博客:  史上最强大的40多个纯cs图形 问题:看了上面的博客思考简单的三角行是怎么形成的? #triangle-up { width: 0; height: 0; border-left: 50px ...

  4. Hadoop学习资料收集

    1.漫画HDFS工作原理  http://blog.csdn.net/netcoder/article/details/7442779 2.马哥教育 http://mageedu.blog.51cto ...

  5. 解决Linux文档显示中文乱码问题以及编码转换

    解决Linux文档显示中文乱码问题以及编码转换 解决Linux文档显示中文乱码问题以及编码转换 使vi支持GBK编码 由于Windows下默认编码是GBK,而linux下的默认编码是UTF-8,所以打 ...

  6. distance.c

    #include "stdio.h" #include "string.h" #include "math.h" #include &quo ...

  7. MFC常用 控制对话框透明属性函数

    void CFloatWnd::OnUpdateTransparent(int iTransparent){ HINSTANCE hInst = LoadLibrary("User32.DL ...

  8. switch函数——Gevent源码分析

    在gevent的源码中,经常能看到switch函数.而不同的类中的switch函数有不同的用法 1. greenlet的switch函数 这里面的greenlet是greenlet库中的greenle ...

  9. skynet配置文件

    启动skynet需要一个配置文件 我们看下examples/config root = "./"         表示根目录是skynet启动时的目录thread = 8     ...

  10. PVRTC 纹理

    iPhone的图形芯片(PowerVR MBX)对一种称为 PVRTC 的压缩技术提供的硬件支持,Apple推荐在开发iPhone应用程序时使用 PVRTC 纹理.他们甚至提供了一篇很好的技术笔记描述 ...