欢迎来到天天文库
浏览记录
ID:18404088
大小:67.50 KB
页数:9页
时间:2018-09-17
《家谱管理系统数据结构》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、#include#include#include#include#defineMAXS100#defineElemtypechartypedefstructBiTNode{intmark;intlevel;charname[50];charbirthday[50];charaddress[MAXS];Elemtypedata;structBiTNode*lc,*rc;}BiTNode,*BiTree;charnametemp[50];//姓名charbirthdaytemp[50];//生日c
2、haraddresstemp[MAXS];//地址charch;intleveltemp;intNth;charsearchdata[50];charsearchname[50];intcount;BiTreetemp;BiTreeCreateBiTree(FILE*fp);voidPrintInfo(BiTreeT);voidPreOrderTS(BiTreeT);voidShowNth(BiTreeT);voidSearchByName(BiTreeT);voidSearchByBirthday(BiTreeT);voidAddChild(BiTreeT);voi
3、dDeleteByName(BiTreeT);voidsearchmenu();voidmenu();voidinsystem();voidclosefile();#include"my.h"voidSearchByName(BiTreeT)//按照姓名查询,输出成员信息{if(T){if(T->lc){if(T->lc->rc){temp=T->lc->rc;while(temp){if(strcmp(temp->name,searchname)==0){count++;printf("此人的信息为:");PrintInfo(temp);printf("此人
4、父兄的信息为:");PrintInfo(T);if(temp->lc->rc){printf("此人孩子的信息为:");temp=temp->lc->rc;while(temp){PrintInfo(temp);temp=temp->rc;}}return;}elsetemp=temp->rc;}}}SearchByName(T->lc);SearchByName(T->rc);}else{printf("请先建立家庭关系");return;}}voidSearchByBirthday(BiTreeT)//按照出生日期查询成员名单{if(T){if(str
5、cmp(T->birthday,searchdata)==0){PrintInfo(T);count++;}}}voidAddChild(BiTreeT)//某成员添加孩子{if(T){if(strcmp(T->name,searchname)==0){count++;temp=(BiTree)malloc(sizeof(BiTNode));printf("请输入添加孩子的姓名:");scanf("%s",temp->name);printf("请输入添加孩子的出生年月:(格式形如:2010-1-1)");scanf("%s",temp->birthday);
6、printf("请输入添加孩子的家庭住址:");scanf("%s",temp->address);temp->level=T->level+1;temp->rc=T->lc->rc;temp->lc=NULL;T->lc->rc=temp;printf("孩子添加成功");return;}AddChild(T->lc);AddChild(T->rc);}else{printf("请先建立家庭关系");return;}}voidDeleteByName(BiTreeT)//删除某成员(若其还有后代,则一并删除){if(T){if(strcmp(T->nam
7、e,searchname)==0){count++;T=NULL;return;}DeleteByName(T->lc);DeleteByName(T->rc);}}BiTreeCreateBiTree(FILE*fp){if(!feof(fp)){BiTreeT;T=(BiTree)malloc(sizeof(BiTNode));fscanf(fp,"%s%s%s",nametemp,birthdaytemp,addresstemp);fscanf(fp,"%d",&leveltemp);if((strcmp(nametemp,"n")==0)
此文档下载收益归作者所有