/*后序遍历*/ void last_tree(node *root) { if(root!=NULL) { last_tree(root->lchild); last_tree(root->rchild); printf("%c\t",root->ch); } }
void last_tree(struct tree *root) { if (root->lc != NULL) { last_tree(root->lc); } if (root->rc != NULL) { last_tree(root->rc); } printf("%c ", root->data); }
void last_tree(struct tree *phead) { if (phead->lc != NULL) { last_tree(phead->lc); } if (phead->rc != NULL) { last_tree(phead->rc); } printf("%d ", phead->data); }
int main(int argc, char const *argv[]) { node *root=init_tree(); pre_tree(root); printf("\n"); mid_tree(root); printf("\n"); last_tree(root); printf("\n"); return 0; }
void show_tree(struct tree *root) { printf("this is first tree:\n"); first_tree(root); printf("\n"); printf("this is middle tree:\n"); middle_tree(root); printf("\n"); printf("this is last tree:\n"); last_tree(root); printf("\n"); }
void show_tree(struct tree *phead) { printf("this is first tree:\n"); first_tree(phead); printf("\n"); printf("this is middle tree:\n"); middle_tree(phead); printf("\n"); printf("this is last tree:\n"); last_tree(phead); printf("\n"); }