嵌入式 一个简单的个人通讯录(基于二叉排序树,带注释)

这是一个实现嵌入式个人通讯录的项目,使用二叉排序树作为数据结构。代码包括了数据结构定义、节点插入、删除、查找和遍历等操作。用户可以添加、修改、查找和删除联系人信息,所有输入信息都会进行合法性检查。
摘要由CSDN通过智能技术生成

TreeNode.h:

  1. #define N 50
  2. typedef structstudent
  3. {
  4. charname[N];
  5. charstudentID[N];
  6. charbrithday[N];
  7. chartele[N];
  8. }TreeData;
  9. typedef structtreenode
  10. {
  11. TreeData * stuinfo;
  12. struct treenode *leftchild;
  13. struct treenode *rightchild;
  14. }TREENODE;
#define N 50

typedef struct student
{
    char name[N];
    char studentID[N];
    char brithday[N];
    char tele[N];
}TreeData;

typedef struct treenode
{
    TreeData * stuinfo;
    struct treenode * leftchild;
    struct treenode * rightchild;
}TREENODE;

Addressbook.h:

  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<stdlib.h>
  4. #include"Treenode.h"
  5. extern TREENODE *mycreatetree();
  6. extern voidmyinsertnode(TREENODE *,TreeData *);
  7. extern voidmycopy(TreeData *,char*,char *,char*,char *);
  8. extern voidmyeva(TreeData *);
  9. extern voidpreorder(TREENODE *);
  10. extern TREENODE*treeinit(TREENODE *);
  11. extern TREENODE *mysearch(TREENODE *,char*);
  12. extern intisfind(TREENODE *,char*);
  13. extern intmycorrect(TREENODE *,char*);
  14. extern TREENODE *findleaf(TREENODE *);
  15. extern TREENODE *findparent(TREENODE *,TREENODE *);
  16. extern voidmyremove(TREENODE *,char*);
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "Treenode.h"

extern TREENODE * mycreatetree();
extern void myinsertnode(TREENODE *,TreeData *);
extern void mycopy(TreeData *,char *,char *,char *,char *);
extern void myeva(TreeData *);
extern void preorder(TREENODE *);
extern TREENODE *treeinit(TREENODE *);
extern TREENODE * mysearch(TREENODE *,char *);
extern int isfind(TREENODE *,char *);
extern int mycorrect(TREENODE *,char *);
extern TREENODE * findleaf(TREENODE *);
extern TREENODE * findparent(TREENODE *,TREENODE *);
extern void myremove(TREENODE *,char *);

Addressbook.c:

  1. #include "Addressbook.h"
  2. void myeva(TreeData*dest)
  3. {
  4. printf("请输入你要添加的姓名:");
  5. scanf("%s",dest->name);
  6. while(1)
  7. {
  8. printf("请输入你要添加的学号(20209XXXX):");
  9. scanf("%s",dest->studentID);
  10. 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')))
  11. {
  12. break;
  13. }
  14. else
  15. {
  16. printf("输入有误!\n");
  17. printf("您输入的数据必须为20209XXXX的格式(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值