|
|
|
@ -1,4 +1,3 @@
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
@ -61,8 +60,8 @@ void Findmaxpath(BTNode* bt, vector <int > apath, int asum)
|
|
|
|
|
{
|
|
|
|
|
if (bt == NULL) //空树直接返回
|
|
|
|
|
return;
|
|
|
|
|
apath.push_back(bt->data); asum += bt->data; //bt结点加入apath
|
|
|
|
|
asum += bt->data; //累计a路径和。
|
|
|
|
|
apath.push_back(bt->data);
|
|
|
|
|
asum += bt->data; //bt结点加入apath
|
|
|
|
|
if (bt->lchild == NULL && bt->rchild == NULL) //bt结点为叶结点
|
|
|
|
|
{
|
|
|
|
|
if (asum - maxsum)
|
|
|
|
@ -96,4 +95,4 @@ int main()
|
|
|
|
|
printf("\n");
|
|
|
|
|
printf("销毁树bt\n");
|
|
|
|
|
DestroyBTree(bt);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|