我需要定义一个读取整数并按升序打印回来的主函数。
For example, if the input contains
12
4
19
6
the program should output
4
6
12
19
但是,我需要使用树木来做到这一点。我可以使用两个功能insertavl
,并且deleteavl
可以随意使用。他们的定义是这样的...... http://ideone.com/8dwlU 基本上当 deleteavl 被调用时,它会删除节点,并相应地重新平衡树......如果有兴趣他们的结构在:http: //ideone.com/ {}}}.
到目前为止,我已经得到了这个:
int main (void) {
int number;
struct node *t = NULL;
while (1 == scanf("%d",&number)) {
t = insertavl(t, number);
}
while (t != NULL){
printf("%d\n",t->data);
t = deleteavl(t, t->data);
}
}
但这不会按升序打印它们。任何的意见都将会有帮助?提前致谢!