// Defines the entry point for the console application.
//二叉树的输入及其遍历(以先序为例)上机练习参考
#include"iostream"
#include "stdlib.h"
#define ok 1;
#define error 0
#define TRUE 1
#define FALSE 0
#define OVERFLOW -1
typedef int Status;
typedef char TElemType;
//定义树
typedef struct BitNode{
诗歌的表现手法 TElemType date;
struct BitNode *lchild,*rchild;
}BiTNode,*BiTree;沾沾自喜什么意思
//构造树
Status CreateBiTree(BiTree &T){
TElemType ch;
scanf("%c",&ch);
if(ch==' ')T=NULL;
el{
if(!(T=(BiTNode*)malloc(sizeof(BiTNode))))exit(OVERFLOW);
T->date=ch;
CreateBiTree(T->lchild);
CreateBiTree(T->rchild);
}
4d打印技术言不由衷的意思 return ok;
浙江玉环}
//树的遍历
Status PreOrderTraver(BiTree T){
if(T){
printf("%c",T->date);printf(" ");
PreOrderTraver(T->lchild);
PreOrderTraver(T->rchild);
}
return ok;
}七宝街
Status InOrderTraver(BiTree T){
职工薪酬会计分录
if(T){
InOrderTraver(T->lchild);
printf("%c",T->date);printf(" ");
InOrderTraver(T->rchild);
}
return ok;
}
Status PostOrderTraver(BiTree T){
if(T){
PostOrderTraver(T->lchild);
PostOrderTraver(T->rchild);
printf("%c",T->date);printf(" ");
}
老犯困 return ok;
}
void main()
{
BiTree T;
printf("\n请创建二叉树,按先序顺序输入各节点的值:\n");
CreateBiTree(T);
printf("\n先序遍历二叉树的结果为:\n");
PreOrderTraver(T);
printf("\n中序遍历二叉树的结果为:\n");
InOrderTraver(T);
printf("\n后序遍历二叉树的结果为:\n");
PostOrderTraver(T);
printf("\n");
printf("Hello World!\n");
}