#include <stdio.h>
#include <string.h>
/**
- 定义一个联系人节点,包括联系人数据,还有下一个联系人节点的地址
/
typedef struct Contact {
char name[50];
char tel[11];
struct Contact next;
struct Contact* prev
} Contact;
/**
- 定义一个通讯录,包括
链表定义1:有一个节点,叫头节点,不存数据,只指向第一个节点
链表定义2:有一个指针,指向第一个节点
*/
typedef struct {
int size;
Contact * head;
Contact * tail;
} ContactList;
//1.增加一个联系人
void add(ContactList* lp, Contact* cp) { //尾插法
if (lp->size == 0) { //空链表
lp->head = cp;
} else {
lp->tail->next = cp;
cp->prev = lp->tail;
}
lp->tail = cp;
lp->size++;
}
//2.查询联系人
Contact* find(ContactList* lp, char* name) {
Contact* tp = lp