#include<stdio.h>
#include<stdlib.h>voidPreorder(int* postorder, int * inorder, int postleft, int postright, int inleft, int inright);
int main(){
int N;//number of TNodescanf("%d",&N);
int* postorder =(int *)malloc(N*sizeof(int));
int* inorder =(int*)malloc(N*sizeof(int));
int i;for(i =0; i <N; i++){scanf("%d",&postorder[i]);}for(i =0; i <N; i++){scanf("%d",&inorder[i]);}printf("Preorder:");Preorder(postorder, inorder,0,N-1,0,N-1);return0;}voidPreorder(int* postorder, int * inorder, int postleft,int postright,int inleft,int inright){if(!(postleft <= postright&&inleft <= inright))return;printf(" %d", postorder[postright]);
int i = inleft;while(inorder[i]!= postorder[postright]) i++;if(i != inleft)Preorder(postorder, inorder, postleft, postleft+i-1-inleft,inleft,i-1);if(i != inright)Preorder(postorder, inorder, postleft+i-inleft, postright-1,i+1,inright);}
练习4.1-根据后序和中序遍历输出先序遍历-编程题解题代码测试结果问题整理解题代码#include<stdio.h>#include<stdlib.h>void Preorder(int* postorder, int * inorder, int postleft, int postright, int inleft, int inright);int main...