对满二叉树,知其先序序列,求后序序列
直接被代码吧,反正也不难
#include <stdio.h> #include <stdlib.h> typedef struct node{ int data; struct node *lchild,*rchild; }TreeNode,*Tree; void PreToLat(int *A,int Afront,int Arear,int *B,int Bfront,int Brear) { int half; if(Arear>=Afront) { B[Brear]=A[Afront]; half=(Arear-Afront)/2; PreToLat(A,Afront+1,Afront+half,B,Bfront,Bfront+half-1); PreToLat(A,Afront+half+1,Arear,B,Bfront+half,Brear-1); } } int main() { Tree T; int A[7]={1,2,4,5,3,6,7}; int B[7]; PreToLat(A,0,6,B,0,6); for(int i=0;i<7;i++) printf("%d ",B[i]); return 0; }
标签:Afront,144,15,int,half,PreToLat,Bfront,Arear From: https://www.cnblogs.com/simpleset/p/17763364.html