0
所以我试图创建一个二叉树使用前序横向链接列表。 我在做这件事时遇到了很多问题,我看到了一些“解决方案”,但我不喜欢它!我在尝试一些简单的事情。从二叉树创建链接列表(先序tranversal)
这是我到现在为止的代码:我得到总空单
typedef struct nodo {
int value;
struct nodo *left, *right;
} *ABin;
typedef struct lligada {
int value;
struct lligada *next;
} *LInt;
void preorder (ABin a, LInt * l) {
LInt r=*l,tmp;
tmp=r;
if (!a) {
*l=NULL;
}
else {
r=malloc(sizeof(struct lligada));
r->value=a->value;
r=r->next;
*l=tmp;
preorder (a->left,l);
preorder (a->right,l);
}
}
!
哦,我的坏!你是对的。 – Bruno
它应该在开始时指向NULL。 – Bruno
我很想去,但我无法更改声明。它由我的老师实施。 – Bruno