没有合适的资源?快使用搜索试试~ 我知道了~
家谱管理系统-数据结构大作业.doc
32 浏览量
2022-12-01
12:31:07
上传
评论
收藏 62KB DOC 举报
家谱管理系统-数据结构大作业.doc
资源推荐
资源详情
资源评论












/* 家谱管理系统
任务:实现具有下列功能的家谱管理系统
功能要求:
1). 输入文件以存放最初家谱中各成员的信息,成员的信息中均应包含以下内容:
姓名、出生日期、婚否、地址、健在否、死亡日期(若其已死亡),也可附加其它信息、但
不是必需的。
2). 实现数据的存盘和读盘。
3). 以图形方式显示家谱。
4). 显示第 n 代所有人的信息。
5). 按照姓名查询,输出成员信息(包括其本人、父亲、孩子的信息)。
6). 按照出生日期查询成员名单。
7). 输入两人姓名,确定其关系。
8). 某成员添加孩子。
9). 删除某成员(若其还有后代,则一并删除)。
10).修改某成员信息。
11).按出生日期对家谱中所有人排序。
12).打开一家谱时,提示当天生日的健在成员。
要求:建立至少 30 个成员的数据,以较为直观的方式显示结果,并提供文稿形式以便检查。
界面要求:有合理的提示,每个功能可以设立菜单,根据提示,可以完成相关的功能要求。
存储结构:学生自己根据系统功能要求自己设计,但是要求相关数据要存储在数据文件中。
测试数据:要求使用 1、全部合法数据;2、局部非法数据。进行程序测试,以保证程序的
稳定。
测试数据及测试结果请在上交的资料中写明;
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
#include"map.h"
#define MAXN 100
#define MAXMEM 100
#define Elemtype char
==============================
//树
typedef struct BiTNode
{
int mark;//标记
int level;
char name[50];//姓名
char birthday[50];//生日
char address[MAXN];//住址

bool marriage;//婚否(true 表示结婚,false 表示没结婚)
bool live;//建在(true 表示活着,false 表示过世)
bool sex;//性别(true 表示男,false 表示女)
char livemassage[50];//死亡日期(如果其已经死亡)
Elemtype data;//
struct BiTNode *lc,*rc;
}BiTNode,*BiTree;
//树的相关操作
char nametemp[50];//姓名
char birthdaytemp[50];//生日
char addresstemp[MAXN];//住址
bool marriagetemp;//婚否(true 表示结婚,false 表示没结婚)
bool livetemp;//建在(true 表示或者,false 表示过世)
bool sextemp;
char livemassagetemp[MAXN];//死亡日期(如果其已经死亡)
char ch;//额外使用
int leveltemp;//人的代数
int Nth;//显示第 n 代人时要用
char searchdata[50];
char searchname[50];
int count;//计数
int choice;//各种选择
int use;
BiTree temp;
struct BiTNodeList
{
BiTree data;
BiTNodeList *next;
};
BiTNodeList *List;
//-----------
void CreatBiTree(BiTree &T,FILE *in)//建立双链二叉树
{
fscanf(in,"%c",&ch);
//printf("%c\n",ch);
if(ch == '@')
{

T = NULL;
fscanf(in,"%c",&ch);
}
else
{
T = (BiTree)malloc(sizeof(BiTNode));
//fscanf(in,"%s%s%s%d%d",nametemp,birthdaytemp,addresstemp,&marriagetemp,&livetemp);
fscanf(in,"%s",nametemp);
strcpy(T->name,nametemp);
fscanf(in,"%s",birthdaytemp);
strcpy(T->birthday,birthdaytemp);
fscanf(in,"%s",addresstemp);
strcpy(T->address,addresstemp);
fscanf(in,"%d%d%d%d",&marriagetemp,&livetemp,&leveltemp,&sextemp);
T->marriage = marriagetemp;
T->live = livetemp;
T->level = leveltemp;
T->sex = sextemp;
//printf("%s %s %s %d
%d\n",nametemp,birthdaytemp,addresstemp,marriagetemp,livetemp);
if(!livetemp)
{
fscanf(in,"%s",livemassagetemp);
//printf("%s\n",livemassagetemp);
}
if(!T->live)
strcpy(T->livemassage,livemassagetemp);
fscanf(in,"%c",&ch);
CreatBiTree(T->lc,in);
CreatBiTree(T->rc,in);
}
}
void PrintInfo(BiTree T)
{
printf("%-10s 出生于:%-10s%-10s",T->name,T->birthday,T->address);
if(T->marriage)
printf("\t 已婚");
if(!T->marriage)
printf("\t 未婚");
if(T->sex)
printf("\t 男");

if(!T->sex)
printf("\t 女");
if(T->live)
printf("\t 健在\n");
if(!T->live)
printf("\t 去世于:%s\n",T->livemassage);
}
void PreOrderTraverse_recursion(BiTree T)//递归 先序遍历(检查建树是否正确)
{
//printf("PreOrderTraverse_recursion\n");
if(T)
{
/*printf("%-10s 出生于:%-10s%-10s",T->name,T->birthday,T->address);
if(T->marriage)
printf("\t 已婚");
if(!T->marriage)
printf("\t 未婚");
if(T->sex)
printf("\t 男");
if(!T->sex)
printf("\t 女");
if(T->live)
printf("\t 健在\n");
if(!T->live)
printf("\t 去世于:%s\n",T->livemassage);*/
PrintInfo(T);
PreOrderTraverse_recursion(T->lc);
PreOrderTraverse_recursion(T->rc);
}
}
void ShowFamilyTree(BiTree T)//以图形的方式显示家谱
{
int i,lev;
BiTree p;
p = T;
if(T)
{
lev = T->level;
for(i=0; i<lev; i++)
printf("\t");
printf("%-5s ",p->name);
剩余17页未读,继续阅读
资源评论

智慧安全方案
- 粉丝: 120
- 资源: 58万+

上传资源 快速赚钱
我的内容管理 收起
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助

会员权益专享
安全验证
文档复制为VIP权益,开通VIP直接复制
