先序遍历: 根 ,左,右 中序遍历: 左 ,根,右 后序遍历: 左 ,右,根 遍历的两种核心方法:1递归,2利用栈实现 1递归实现 #include<malloc.h> #include <string> #include <iostream> using namespace std; #define OK 1 #define FALSE 0 typedef char status; typedef struct Node { status data; struct Node *LTree,*RTree; }BinaryTree; /*PreCreateTree先序创建BinaryTree*/ void PreCreateTree(BinaryTree* & head) { char ch; scanf("%c",&ch); if(ch=='#') { head=NULL; } else { head=(BinaryTree *)malloc(sizeof(BinaryTree)); head->data=ch; PreCreateTree(head->LTree); PreCreateTree(head->RTree); } } void InOrderTraverse(BinaryTree *head) { if (head) { InOrderTraverse(head->LTree); printf("%c",head->data); InOrderTraverse(head->RTree);