void preprint(struct BT *root) { if(root) { printf("[%d]\t",root->data); preprint(root->l); preprint(root->r); } }
void preprint(node *tree,int print[]) { if(tree!=NULL) { //printf("%d ",tree->data); print[hh]=tree->data; hh++; preprint(tree->left,print); preprint(tree->right,print); } return; }
main() { int pre[]={3,5,2,6,7,1,4}; int in[]={1,2,3,4,5,6,7}; struct BT *rt; int n=sizeof(pre)/sizeof(pre[0]); printf("%d",n); rt=built(in,pre,0,n-1); printf("\n\n"); inprint(rt); printf("\n\n"); preprint(rt); printf("\n\n"); //struct BT *rt1=builtBT(pre,in,0,n-1); //inprint(rt1); //printf("\n\n"); //preprint(rt1); //printf("\n\n"); }
void errorHandler::printError(std::ostream &out, const std::string &message) { ++errors; preprint(out); occa::printError(out, message); postprint(out); }
void errorHandler::printWarning(std::ostream &out, const std::string &message) { ++warnings; preprint(out); occa::printWarning(out, message); postprint(out); }
//void del(node *tree,int num); int main() { int test,c=0; //scanf("%d",&test); int n,z=0,numb; node *tree; tree=NULL; scanf("%d",&n); int print[n]; int a[n+1],b[n+1]; while(z<n) { scanf("%d",&b[z]); z++; } z=0; while(z<n) { scanf("%d",&a[z]); z++; } x=n; tree=insert(tree,0,n-1,0,n-1,b,a); scanf("%d",&numb); while(tree->data!=numb) { tree=rotate(tree,numb); } inprint(tree,print); for(z=0;z<hh-1;z++) {printf("%d ",print[z]); } printf("%d\n",print[hh-1]); hh=0; preprint(tree,print); for(z=0;z<hh-1;z++) {printf("%d ",print[z]); } printf("%d\n",print[hh-1]); hh=0; postprint(tree,print); for(z=0;z<hh-1;z++) {printf("%d ",print[z]); } printf("%d\n",print[hh-1]); hh=0; /*for(i=0;i<j;i++) { printf("%d\n",a[i]); printf("%d\n",b[i]); }*/ return 0; }
void errorHandler::printNote(std::ostream &out, const std::string &message) { preprint(out); occa::printNote(out, message); postprint(out); }