#include <stdio.h>
void AllPath(BTNode *b,ElemType path[],int pathlen)
{
int i;
if (b!=NULL)
{
if (b->lchild==NULL && b->rchild==NULL) //*b为叶子结点
{
cout << " " << b->data << "到根结点路径:" << b->data;
for (i=pathlen-1;i>=0;i--)
cout << endl;
}
else
{
path[pathlen]=b->data; //将当前结点放入路径中
pathlen++; //路径长度增1
AllPath(b->lchild,path,pathlen); //递归扫描左子树
AllPath(b->rchild,path,pathlen); //递归扫描右子树
pathlen--; //恢复环境
}
}// if (b!=NULL)
}//算法结束
int main () {
//JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。
printf("Hello JSRUN! \n\n - from C .");
return 0;
}