如何将树中节点的值复制到另一个变量中 [英] how to copy the value of a node in a tree into another variable

查看:99
本文介绍了如何将树中节点的值复制到另一个变量中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究这个项目,它显示了一个真正形状的二叉树,并且要做我想要将整个树复制到一个空间喜欢的列表中我保留信息的
每个节点的价值,它是否是假??,它的级别是什么?为了方便地打印它?b $ b但问题是我无法将节点的值复制到喜欢的列表中节点

i试图使用另一个变量,但它不会工作

这里是一个代码示例:

I have been working on this project that displays a binary tree in its real shape and to to do
that I am trying to copy the entire tree into a spacial liked list where i keep information about each node its value ,is it a leave or not ?,what is its level ..in order to print it conveniently
but the problem is that i cant copy the value of a node into the liked list's node
i tried to use another variable but it just wont work
here is a sample of the code :

void const_llc_arbre(noeud *racine,maillon**tete,int *cpt,maillon **q)
{
                 maillon *p;(node)(the node of the linked list)
                 allouer(&p);
                 int valeur;/** its in french !**/(value)
                 valeur=racine->info;(node->value)
                 p->val=valeur;
                 p->suiv=NULL;
                 p->niv=profondeur(racine);(the level of the node)
                if(*cpt==0){*tete=p;}(head of liked list)
                else
                {
                                (*q)->suiv=p;(next)
                }
                *q=p;
                (*cpt)++;
                const_llc_arbre(racine->fd,&(*tete),&(*cpt),&(*q));(right son)
                const_llc_arbre(racine->fg,&(*tete),&(*cpt),&(*q));(left son)
}

推荐答案

这篇关于如何将树中节点的值复制到另一个变量中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆