#ifndef PARENTSCHILDREN_H_INCLUDED
#define PARENTSCHILDREN_H_INCLUDED
#include
#include
#define Maxsize 100
typedef struct ANode
{
int adjchild;//
struct ANode *nextchild;//
}ArcNode;
typedef struct JDdate
{
char name[20];
char sex[10];
char birthday[20];
char wifename[20];
char thing[100];
char relationship[30];
}ElemType;
typedef struct VNode//
{
ElemType data;//
int adjparents;//
ArcNode *firstchild;//
}st;
void CreatTree(int n);//
void InputTree(int n);//
void InestTree(int n);//
void DeleteTree(int n);//
void ReviseTree(int n);//
void SearchTree(int n);//
int system(const char *string);//
#endif // PARENTSCHILDREN_H_INCLUDED
#include
#include
#include
#include"ParentsChildren.h"
st Pt[Maxsize];//
/********************* **********************/
void CreatTree(int n)//n
{
system("cls");
int i,j,p=0,q=0,d;
ArcNode *m=NULL,*w=NULL;
char namechild[20];
char nameparents[20];
for(i=0; iadjchild=p;
m->nextchild=NULL;
w=m;
}
else
{
m=(ArcNode*)malloc(sizeof(ArcNode));
w->nextchild=m;
m->adjchild=p;
w=m;
}
w->nextchild=NULL;
}
printf(" !
");
}
/*********************** **********************/
void InputTree(int n)
{
system("cls");
int a;
for(int i=0; iadjchild;
printf(" %s %s %s %s %s %s
",Pt[a].data.name,Pt[a].data.sex,Pt[a].data.birthday,Pt[a].data.wifename,Pt[a].data.thing,Pt[a].data.relationship);
w=w->nextchild;
}
printf("
");
}
}
/********************* **********************/
void InestTree(int n)
{
system("cls");
int p,q;
ArcNode *m=NULL;
char namechild[20];
char nameparents[20];
printf(" :
");
scanf("%s%s",nameparents,namechild);
for(int i=0; iadjchild=p;
m->nextchild=Pt[q].firstchild;
Pt[q].firstchild=m;
printf(" !
");
}
/************************ ***************************/
void DeleteTree(int n)
{
system("cls");
char nameDelete[20];
printf(" :
");
scanf("%s",nameDelete);
for(int i=0;i
#include
#include"ParentsChildren.h"
int main()
{
int n,m;
printf(" :
");
scanf("%d",&m);
while(1)
{
printf(" :1. .2. 3. 4. 5. 6. 7.
");
scanf("%d",&n);
switch(n)
{
case 1:CreatTree(m);break;
case 2:InputTree(m);break;
case 3:InestTree(m);break;
case 4:DeleteTree(m);break;
case 5:ReviseTree(m);break;
case 6:SearchTree(m);break;
case 7:exit(1);break;
default :printf(" !
");break;
}
}
return 0;
}