TreeNode.h:
- #define N 50
- typedef structstudent
- {
- charname[N];
- charstudentID[N];
- charbrithday[N];
- chartele[N];
- }TreeData;
- typedef structtreenode
- {
- TreeData * stuinfo;
- struct treenode *leftchild;
- struct treenode *rightchild;
- }TREENODE;
Addressbook.h:
- #include<stdio.h>
- #include<string.h>
- #include<stdlib.h>
- #include"Treenode.h"
- extern TREENODE *mycreatetree();
- extern voidmyinsertnode(TREENODE *,TreeData *);
- extern voidmycopy(TreeData *,char*,char *,char*,char *);
- extern voidmyeva(TreeData *);
- extern voidpreorder(TREENODE *);
- extern TREENODE*treeinit(TREENODE *);
- extern TREENODE *mysearch(TREENODE *,char*);
- extern intisfind(TREENODE *,char*);
- extern intmycorrect(TREENODE *,char*);
- extern TREENODE *findleaf(TREENODE *);
- extern TREENODE *findparent(TREENODE *,TREENODE *);
- extern voidmyremove(TREENODE *,char*);
Addressbook.c:
- #include "Addressbook.h"
- void myeva(TreeData*dest)
- {
- printf("请输入你要添加的姓名:");
- scanf("%s",dest->name);
- while(1)
- {
- printf("请输入你要添加的学号(20209XXXX):");
- scanf("%s",dest->studentID);
- if((strlen(dest->studentID)== 9) &&(dest->studentID[0] == '2')&&(dest->studentID[1] == '0')&&(dest->studentID[2] == '2')&&(dest->studentID[3] == '0')&&(dest->studentID[4] == '9')&&((dest->studentID[5]<= '9')&&(dest->studentID[5]>= '0'))&&((dest->studentID[6]<= '9')&&(dest->studentID[6]>= '0'))&&((dest->studentID[7]<= '9')&&(dest->studentID[7]>= '0'))&&((dest->studentID[8]<= '9')&&(dest->studentID[8]>= '0')))
- {
- break;
- }
- else
- {
- printf("输入有误!\n");
- printf("您输入的数据必须为20209XXXX的格式(