欢迎来到一句话经典语录网
我要投稿 投诉建议
当前位置:一句话经典语录 > 心得体会 > 二叉树编译心得体会

二叉树编译心得体会

时间:2014-09-20 14:30

二叉树遍历算法,谁能告诉我错在哪里

编译一直不通过

struct BiTNode { char data; struct BiTNode *lchild; struct BiTNode *rchild;}BiTNode, *BiTree;改成:typedef struct BiTNode {char data;struct BiTNode *lchild;struct BiTNode *rchild;}BiTNode, *BiTree;主函数中调用函数方式出错改为 CreatBiTree(T); printf(The PreTravel is:\\\ ); PreTravel(T); printf(\\\ ); printf(The PostTravel is:\\\ ); PostTravel(T); printf(\\\ ); printf(The MidTravel is:\\\ ); MidTravel(T);

二叉树与二叉排序树编译

输入树的节点,输入0结束1 2 3 4 5 6 7 8 9 0中序打印1->2->3->4->5->6->7->8->9->后序打印9->8->7->6->5->4->3->2->1->前序打印1->2->3->4->5->6->7->8->9->\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/ #include #include typedef struct tree { struct tree *left; int date; struct tree *right; }treenode,*b_tree; \\\/\\\/\\\/\\\/\\\/\\\/\\\/按顺序插入节点\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/b_tree insert(b_tree root,int node){ b_tree newnode; b_tree currentnode; b_tree parentnode; newnode=(b_tree)malloc(sizeof(treenode)); newnode->date=node; newnode->right=NULL; newnode->left=NULL; if(root==NULL) return newnode; else { currentnode=root; while(currentnode!=NULL) { parentnode=currentnode; if(currentnode->date>node) currentnode=currentnode->left; else currentnode=currentnode->right; } if(parentnode->date>node) parentnode->left=newnode; else parentnode->right=newnode; } return root;} \\\/\\\/\\\/\\\/\\\/\\\/建立树\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/b_tree creat(int *date,int len){ b_tree root=NULL; int i; for(i=0;ileft); printf(%d->,root->date); print1(root->right);}}\\\/\\\/\\\/\\\/\\\/\\\/后序打印\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/void print2(b_tree root){if(root!=NULL){ print2(root->left); print2(root->right); printf(%d->,root->date);}}\\\/\\\/\\\/\\\/\\\/\\\/前序打印\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/void print3(b_tree root){if(root!=NULL){ printf(%d->,root->date); print3(root->left); print3(root->right);}}\\\/\\\/\\\/\\\/\\\/\\\/\\\/测试函数\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/\\\/void main(){ b_tree root=NULL; int i,index; int value; int nodelist[20]; printf(输入树的节点,输入0结束\\\ ); index=0; scanf(%d,value); while(value!=0) { nodelist[index]=value; index=index+1; scanf(%d,value); } root=creat(nodelist,index); printf(\\\ 中序打印\\\ ); print1(root); printf(\\\ 后序打印\\\ ); print2(root); printf(\\\ 前序打印\\\ ); print3(root);}

VC++二叉树编译时的指针问题

向高手求救啊

if (n <= 0) return 0 ; \\\/\\\/ 出错地方之一, error C2440: 'return' : cannot convert from 'const int' to 'class 这里怎么能返回0呢,和你的函数定义不一致.

二叉树中序遍历里面有printf语句但是没有相应输出,愁了我几天了,编译也没有问题

你在SORTTREE()中创建的树T和主函数的树T不一样,只需要把SORTTREE(k,i+1);改成T=SORTTREE(k,i+1);即可. 即把SORTTREE()的值返回给主函数的二叉树T。

二叉树的建立为什么编译没有错误,但是不出结果

bitree *root=new bitree 可以有问题,它又声明了一个新局部变量另外只有内存申请,没有释放,有可能会有问题还有prebitree定义在哪里

声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。联系xxxxxxxx.com

Copyright©2020 一句话经典语录 www.yiyyy.com 版权所有

友情链接

心理测试 图片大全 壁纸图片