)
一、Contact.h1.1.作用定义个人信息结构体peoInfo和常量。1.2.代码代码如下#pragma once#includestdio.h#includestdlib.h#includestring.h#includeassert.h#define MAX_NAME 20#define MAX_PHONE 20#define MAX_GENDER 10#define MAX_ADDR 20typedef struct peoInfo{char name[MAX_NAME];int age;char gender[MAX_GENDER];char addr[MAX_ADDR];char phone[MAX_PHONE];}peoInfo;struct SeqList;二、SeqList.h2.1.作用定义顺序表结构设置数据类型为peoInfo并将顺序表别名为Contact。2.2.代码代码如下#pragma once#includeContact.htypedef peoInfo SLDataType;typedef struct SeqList {SLDataType* a;int size;int capacity;}SL;typedef struct SeqList Contact;// 前置声明告诉编译器有一个叫 SeqList 的结构体因为 Contact.h 需要被 SeqList.h 包含而 SeqList 的定义在 SeqList.h 中 为了避免循环依赖这里只声明具体定义在 SeqList.hvoid SLCheckCapacity(SL* sl);void SLprint(SL* sl);void SLInit(SL* sl);void SLPushFront(SL* sl, SLDataType x);void SLPushBack(SL* sl, SLDataType x);void SLInsert(SL* sl, int pos, SLDataType x);void SLRemoveAll(SL* sl, SLDataType x);void SLPopFront(SL* sl);void SLPopBack(SL* sl);void SLErase(SL* sl, int pos);//查找元素int SLFind(SL* sl, SLDataType x);//修改指定位置的数据void SLModify(SL* sl, int pos, SLDataType);三、3-23.c3.1.作用实现顺序表的底层增删查改逻辑。3.2.代码代码如下// 打印单个void PrintOne(const peoInfo* p) {printf(%-10s %3d %-6s %-15s %-20s\n, p-name, p-age, p-gender, p-tel, p-addr);}// 打印所有void SLPrint(SL* sl) {assert(sl);if (sl-size 0) {printf(通讯录为空。\n);return;}printf(\n%-10s %-5s %-6s %-15s %-20s\n, 姓名, 年龄, 性别, 电话, 地址);printf(------------------------------------------------------------\n);for (int i 0; i sl-size; i) {PrintOne(sl-a[i]);}printf(------------------------------------------------------------\n);}