#include <stdio.h>
#include <stdlib.h>
#include <time.h>
typedef struct tree{
int key;
struct tree *left;
struct tree *right;
} tree;
tree * insert(tree *root, int new_value){
if(root == NULL){
root = (tree *)malloc(sizeof(tree));
root->key = new_value;
root->left = root->right = NULL;
return root;
}
if(root->key > new_value)
root->left = insert(root->left, new_value);
else
root->right = insert(root->right, new_value);
}
void postorder(tree *root){
if(root == NULL)
return;
postorder(root->left);
postorder(root->right);
printf("%d ", root->key);
}
int main(){
int i, k;
tree *root = NULL;
srand(time(NULL));
for(i = 0; i < 10; i++){
k = rand() % 17;
root = insert(root, k);
}
postorder(root);
scanf("%d", &i);
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHRpbWUuaD4KCnR5cGVkZWYgc3RydWN0IHRyZWV7CglpbnQga2V5OwoJc3RydWN0IHRyZWUgKmxlZnQ7CglzdHJ1Y3QgdHJlZSAqcmlnaHQ7Cn0gdHJlZTsKCnRyZWUgKiBpbnNlcnQodHJlZSAqcm9vdCwgaW50IG5ld192YWx1ZSl7CglpZihyb290ID09IE5VTEwpewoJCXJvb3QgPSAodHJlZSAqKW1hbGxvYyhzaXplb2YodHJlZSkpOwoJCXJvb3QtPmtleSA9IG5ld192YWx1ZTsKCQlyb290LT5sZWZ0ID0gcm9vdC0+cmlnaHQgPSBOVUxMOwoJCXJldHVybiByb290OwoJfQoJaWYocm9vdC0+a2V5ID4gbmV3X3ZhbHVlKQoJCXJvb3QtPmxlZnQgID0gaW5zZXJ0KHJvb3QtPmxlZnQsIG5ld192YWx1ZSk7CgllbHNlCgkJcm9vdC0+cmlnaHQgPSBpbnNlcnQocm9vdC0+cmlnaHQsIG5ld192YWx1ZSk7Cn0KCnZvaWQgcG9zdG9yZGVyKHRyZWUgKnJvb3QpewoJaWYocm9vdCA9PSBOVUxMKQoJCXJldHVybjsKCXBvc3RvcmRlcihyb290LT5sZWZ0KTsKCXBvc3RvcmRlcihyb290LT5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