数据结构课程设计总结报告(3)

2019-04-01 17:46

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]){


数据结构课程设计总结报告(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:采购付款制度及流程

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: