|
楼主 |
发表于 2004-6-11 09:21:16
|
显示全部楼层
是啊 不过还是有错误啊
我输入1 2 3 0 4 0 0 5 0 0 6 0 7 8 0 0 9 0 0
后 前三个可以正确输出,后面又是段错误~ 我看看吧
由于是用的递归,最后好像要1 2 3 4 5 0 0 0 0 0 0才好
[code:1]
please you put the data:1 2 3 4 5 0 0 0 0 0 0
The 1898329 dian address is: 1132560010 ,the data is 1 ,the lchild is 0 ,the rchild is 0
please you put the data: The 1898330 dian address is: 1132560030 ,the data is 2 ,the lchild is 0 ,the rchild is 0
please you put the data: The 1898331 dian address is: 1132560050 ,the data is 3 ,the lchild is 0 ,the rchild is 0
please you put the data: The 1898332 dian address is: 1132560070 ,the data is 4 ,the lchild is 0 ,the rchild is 0
please you put the data: The 1898333 dian address is: 1132560110 ,the data is 5 ,the lchild is 0 ,the rchild is 0
[/code:1]
最后出现的是段错误
我输入是这么个结果 是否应该输入一个按一下回车那?
哦 再
void vis_a(pint t)
{
if (!t) return;
if (t->data==0) return;
printf("the jiedian adress is %o,data is %d, lchild is %o,rchild is %o\n ",t,t->data,t->left,t->right);
vis_a(t->left);
vis_a(t->right);
return;
}
加了一个if (!t) return; 可以正常显示了,不过最后还是显示了一个段错误 |
|