return 0; } inittree(T);
fscanf(fp,\从文件读入姓名 strcpy(T->data,name); T->lchild=NULL; T->rchild=NULL; T->parent=NULL; fclose(fp);
if((fp=fopen(filename,\ {
printf(\家谱打开失败!\\n\ return 0; }
fscanf(fp,\ while(!feof(fp)){ if(loc(T,P,name)){ fscanf(fp,\
Q=(BiTPNode *)malloc(sizeof(BiTPNode)); strcpy(Q->data,name);
P->lchild=Q; //构建孩子 Q->parent=P;
Q->lchild=NULL; Q->rchild=NULL; N=P; } else if(!loc(T,P,name)){
Q=(BiTPNode *)malloc(sizeof(BiTPNode)); R=N; R=R->lchild; while(R){
M=R; R=R->rchild;} strcpy(Q->data,name); M->rchild=Q; Q->parent=M; Q->lchild=NULL; Q->rchild=NULL;} fscanf(fp,\ }
printf(\信息载入成功,按任一键继续!\ getch(); return 1; }
//添加成员
status in(BiPTree&T){ char father[10],name[10]; BiPTree Q,M; system(\
printf(\请输入要添加到该家谱中的人的父亲姓名:\ getchar(); gets(father);
while(!loc(T,P,father)){
printf(\不在该家谱中!请重新输入:\ gets(father);}
printf(\请输入要添加到该家谱中的人的姓名:\ gets(name);
Q=(BiTPNode *)malloc(sizeof(BiTPNode)); M=(BiTPNode *)malloc(sizeof(BiTPNode)); strcpy(Q->data,name); Q->lchild=NULL; Q->rchild=NULL; if(!P->lchild){ P->lchild=Q;
Q->parent=P;} else {
P=P->lchild; while(P){
M=P; P=P->rchild;} M->rchild=Q; Q->parent=M; }
printf(\成员添加成功,按任一键继续!\ getch(); return 1; }
//删除成员
status de(BiPTree&T){ char name[10]; system(\
printf(\请输入要删除的人的姓名:\ getchar(); gets(name);
while(!loc(T,P,name)){
printf(\不在该家谱中!请重新输入:\ gets(name);} if(!P->rchild){
if(P->parent->lchild==P)
P->parent->lchild=NULL; else
P->parent->rchild=NULL; free(P);} else if(P->rchild){ if(P->parent->lchild==P)
P->parent->lchild=P->rchild; else
P->parent->rchild=P->rchild; free(P);}
printf(\成员删除成功,按任一键继续!\ getch(); return 1; }
status Show(TElemType e[10]){