家谱管理系统数据结构
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#include
#include
#include
#include
#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 PrintInfo(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();
#include"my.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)==0)
{
count++;
printf("\n此人的信息为: \n");
PrintInfo(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)==0)
{
PrintInfo(T);
count++;
}
}
}
void AddChild(BiTree T)//某成员添加孩子
{
if(T)
{
if(strcmp(T->name,searchname)==0)
{
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)==0)