printf(\ \ return 1; }
//二叉树的遍历
status pre(BiPTreeT,status(*visit)(TElemType[10])){ if(T) {
if ((*visit)(T->data)) if (pre(T->lchild,visit))
if (pre(T->rchild,visit)) return 1; return 0; }
else return 1; }
//家族成员查询 status Sea(BiPTree T){ char name[10]; BiPTree N;
N=(BiTPNode *)malloc(sizeof(BiTPNode));
system(\
printf(\请输入要查寻的人的姓名:\ getchar(); gets(name);
while(!loc(T,P,name)){
printf(\不在该家谱中!请重新输入:\ gets(name);} N=P; if(P==T)
printf(\的父亲在该家谱中没有记载!\\n\ else {
while(N->parent->rchild==N) N=N->parent;
printf(\的父亲是:%s\\n\ N=P; if(P==T)
printf(\没有兄弟!\\n\ else if(!P->rchild&&P->parent->rchild!=P) printf(\没有兄弟!\\n\ else {
printf(\的兄弟有:\\n\ while(N->rchild){
printf(\ N=N->rchild;} N=P;
while(N->parent->rchild==N){ printf(\ N=N->parent;} printf(\ } if(P==T)
printf(\的祖先在该家谱中没有记载!\\n\ else
printf(\的祖先是:%s\\n\ N=P; if(!P->lchild){
printf(\没有孩子!\\n\ printf(\没有后代\\n\ else {
printf(\的孩子有:\\n\ printf(\ N=N->lchild; while(N->rchild){
printf(\
N=N->rchild;} printf(\
printf(\的后代有:\\n\ pre(P->lchild,Show); printf(\ }
printf(\按任一键继续!\ getch(); return 1; }
//文件的创建
status write(BiPTreeT,char filename[40]){ FILE *fp;
if((fp=fopen(filename,\ {
printf(\文件创建失败!\\n\ return 0; }
fprintf(fp,\ T=T->lchild; while(T){
fprintf(fp,\ T=T->rchild;} fprintf(fp,\输出 fclose(fp); return 1; } status
prewrite(BiPTreeT,status(*visit)(BiPTree,char[40]),char filename[40]){ if(T) { if (T->lchild)
(*visit)(T,filename); prewrite(T->lchild,visit,filename); prewrite(T->rchild,visit,filename); return 1;} else return 1; }