(完整word版)家谱管理系统数据结构.docVIP

  • 74
  • 0
  • 约4.18千字
  • 约 10页
  • 2021-10-02 发布于天津
  • 举报
#includestdio.h #includestring.h #includestdlib.h #includeconio.h #define MAXS 100 #define Elemtype char typedef struct BiTNode { int mark; int level; char name[50]; char birthday[50]; char address[MAXS]; Elemtype data; struct BiTNode *lc,*rc; }BiTNode,*BiTree; char nametemp[50];〃 姓名 char birthdaytemp[50];〃 生日 char addresstemp[MAXS];〃 地址 char ch; int leveltemp; int Nth; char searchdata[50]; char searchname[50]; int count; BiTree temp; BiTree CreateBiTree(FILE *fp); void Printlnfo(BiTree T); void PreOrderTS(BiTree T); void ShowNth(BiTree T); void SearchByName(BiTree T); void SearchByBirthday(BiTree T); void AddChild(BiTree T); void DeleteByName(BiTree T); void searchmenu(); void menu(); void insystem(); void closefile(); #includemy.h void SearchByName(BiTree T)〃按照姓名查询,输出成员信息 if(T) if(T-lc) if(T-lc-rc) { temp=T-lc-rc; while(temp) { if(strcmp(temp-name,searchname)==O) { count++; printf(\n此人的信息为:\n); Printlnfo(temp); printf(此人父兄的信息为:\n); PrintInfo (T); if(temp-lc-rc) { printf(此人孩子的信息为:\n); temp=temp-lc-rc; while(temp) { PrintInfo(temp); temp=temp-rc; } } return; } else temp=temp-rc; SearchByName(T-lc); SearchByName(T-rc); } else { printf(请先建立家庭关系\n); return; } } void SearchByBirthday(BiTree T)〃按照出生日期查询成员名单 if(T) { if(strcmp(T-birthday,searchdata)==O) { Printinfo (T); count++; } } } void AddChild(BiTree T)〃 某成员添加孩子 { if(T) { if(strcmp(T-name,searchname)==O) { count++; temp=(BiTree)malloc(sizeof(BiTNode)); printf(请输入添加孩子的姓名:\n); scanf(%s,temp-name); printf(请输入添加孩子的出生年月:(格式形如:2010-1-1)\n); scanf(%s,temp-birthday); printf(请输入添加孩子的家庭住址:\n); scanf(%s,temp-address); temp-level=T-level+1; temp-rc=T-lc-rc; temp-lc=NULL; T-lc-rc=temp; printf(孩子添加成功\n); return; } AddChild(T-lc); AddChild(T-rc); } else { printf(请先建立家庭关系\n); return; } } void DeleteByName(BiTree T)//删除某成员(若其还有后代,则一并删除) { if(T) if(strcmp(T-name,searchname)==O) count++; T=NULL; return; } DeleteByName(T-lc); DeleteByName(T-rc); } } BiTree CreateBiTree(FILE *fp) { if(!feof(fp)) { BiTree T; T=(BiTree)malloc(sizeof(BiTNod

文档评论(0)

1亿VIP精品文档

相关文档