c语言计算机二叉树中各节点中最大元素的值

来源:互联网 发布:河南省考行测成绩算法 编辑:程序博客网 时间:2024/06/05 11:01
#include <stdio.h>//头文件# #include <stdlib.h> #include <malloc.h>  typedef struct BiTNode {       int data;        struct BiTNode *lchild,*rchild;   }  BiTNode,*BiTree; //定义结点类型  int max=-100;//把max定义得足够小 int Max(BiTree T)//求最大(递归算法)        {            if(T==NULL) return 0;                 if(T!=NULL){                     if(T->data>max)                                max=T->data;                            Max(T->lchild);                            Max(T->rchild);                        }             return max;     } 

参考资料

https://zhidao.baidu.com/question/362481305635479372.html

原创粉丝点击