当前位置: 首页 > news >正文

北京pk10网站建设长沙品牌推广公司

北京pk10网站建设,长沙品牌推广公司,wordpress 网站加载过慢,查询注册公司信息在哪里查一.前言 嗨嗨嗨#xff0c;又和大家见面了#xff01;前面我们讲到了如何实现一个循序表。现在我们开始讲解如何基于循序表来实现通讯录功能。 二.正文 通讯录中的SeqlList.h #pragma once //#define SLDateType int #includestdio.h #includestdlib.h #…一.前言 嗨嗨嗨又和大家见面了前面我们讲到了如何实现一个循序表。现在我们开始讲解如何基于循序表来实现通讯录功能。 二.正文 通讯录中的SeqlList.h #pragma once //#define SLDateType int #includestdio.h #includestdlib.h #includeassert.h #includeContact.h typedef PerInfo SLDateType;//通讯录中SeqList.h与顺序表中SeqList.h的区别只是在通讯录中将int换成了结构体PerInfo typedef struct SeqList {SLDateType* arr;int size;int capacity; }SL; void SLInit();//循序表的初始化 void SLDestroy();//顺序表的销毁 void SLPushBack();//尾部插入 void SLPushFront();//头部插入 void SLPopBack();//尾部删除 void SLPopFront();//头部删除 void SLInsert();//指定位置插入 void SLErase();//指定位置删除 int SLFind();//查找数据 通讯录中的Contact.h #pragma once #define NAME_MAX 20 #define GENDER_MAX 20 #define TEL_MAX 20 #define ADDR_MAX 20 typedef struct PersonInfo {char name[NAME_MAX];char gender[GENDER_MAX];int age;char tel[TEL_MAX];char addr[ADDR_MAX]; }PerInfo; typedef struct SeqList Contact; void ContactInit(Contact* con);//通讯录的初始化 void ContactDestroy();//通讯录的销毁 void ContactAdd();//通讯录添加数据 void ContactDel();//通讯录删除数据 void ContactModify();//通讯录修改数据 int ContactFind();//通讯录查找数据 void ContactShow();//通讯录展示数据 通讯录中的SeqList.c #includeSeqList.h void SLInit(SL* ps)//循序表的初始化函数的实现 {ps-arr NULL;ps-size ps-capacity 0; } void SLDestroy(SL* ps)//顺序表销毁的函数实现 {if ((ps-arr) ! NULL){free(ps-arr);}ps-arr NULL;ps-size ps-capacity 0; } void SLCheckCapacity(SL* ps) {if (ps-capacity ps-size){int NewCapacity ps-capacity 0 ? 6 : 2 * ps-capacity;SLDateType* tmp (SLDateType*)realloc(ps-arr, NewCapacity * sizeof(SLDateType));if (tmp NULL){perror(realloc faile!);return ;}ps-arr tmp;ps-capacity NewCapacity;}} //void SLPrint(SL* ps) //{ // for (int i 0; i ps-size; i) // { // printf(%d , ps-arr[i]); // } // printf(\n); //} //void SLPrint(SL s) //{ // for (int i 0; i s .size; i) // { // printf(%d , s.arr[i]); // } // printf(\n); //} void SLPushBack(SL* ps, SLDateType x)//尾插函数的实现 {assert(ps);SLCheckCapacity(ps);ps-arr[ps-size] x;ps-size; } void SLPushFront(SL* ps, SLDateType x)//头插函数的实现 {assert(ps);SLCheckCapacity(ps);for (int i ps-size; i 0; i--){ps-arr[i] ps-arr[i - 1];}ps-arr[0] x;ps-size; } void SLPopBack(SL* ps)//尾删函数的实现 {assert(ps);assert(ps-size);ps-size--; } void SLPopFront(SL* ps)//头删函数的实现 {for (int i 0; i (ps-size) - 1; i){ps-arr[i] ps-arr[i 1];}ps-size--; } void SLInsert(SL* ps, int pos, SLDateType x)//指定位置的插入 {assert(ps);assert(pos 0 pos ps-size);SLCheckCapacity(ps);for (int i ps-size; i pos 1; i--){ps-arr[i] ps-arr[i - 1];}ps-arr[pos] x;ps-size; } void SLErase(SL* ps, int pos) {assert(ps);assert(pos 0 pos ps-size);for (int i pos; i ps-size - 2; i){ps-arr[i] ps-arr[i 1];}ps-size--; } //int SLFind(SL* ps, SLDateType x) //{ // assert(ps); // for (int i 0; i ps- size; i) // { // if (ps-arr[i] x) // { // return i; // } // } // return -1; //} 通讯录中的Contact.c #define _CRT_SECURE_NO_WARNINGS #includeSeqList.h #includeSeqList.h #includeContact.h #includestring.h void ContactInit(Contact* con) {SLInit(con);} void ContactDestroy(Contact* con) {SLDestroy(con); }void ContactAdd(Contact* con) {PerInfo pf;printf(请输入用户的姓名\n);scanf(%s, pf.name);printf(请输入用户的性别\n);scanf(%s, pf.gender);printf(请输入用户的年龄\n);scanf(%d, pf.age);printf(请输入用户的电话\n);scanf(%s, pf.tel);printf(请输入用户的地址\n);scanf(%s, pf.addr);SLPushBack(con, pf); }int ContactFind(Contact* con,char name[]){for (int i 0; i con-size; i){if (0strcmp(con-arr[i].name, name)){return i;}}return -1;}void ContactDel(Contact* con){char name[NAME_MAX];printf(请输入你要删除的联系人姓名\n);scanf(%s, name);int find ContactFind(con, name);if (find 0){printf(没有找到该联系人\n);ContactShow(con);return;}else{SLErase(con, find);printf(删除成功\n);return;}}void ContactShow(Contact* con){printf(姓名 );printf(性别 );printf(年龄 );printf(电话 );printf(地址 );printf(\n);for (int i 0; i con-size; i){printf(%s ,con-arr[i].name);printf(%s , con-arr[i].gender);printf(%d , con-arr[i].age);printf(%s , con-arr[i].tel);printf(%s , con-arr[i].addr);printf(\n);}}void ContactModify(Contact* con){char name[NAME_MAX];printf(输入要修改人姓名\n);scanf(%s, name);int find ContactFind(con, name);if (find 0){printf(要修改的联系人数据不存在\n);ContactShow(con);return;}//直接修改printf(请输入新的姓名\n);scanf(%s, con-arr[find].name);printf(请输入新的性别\n);scanf(%s, con-arr[find].gender);printf(请输入新的年龄\n);scanf(%d, con-arr[find].age);printf(请输入新的电话\n);scanf(%s, con-arr[find].tel);printf(请输入新的住址\n);scanf(%s, con-arr[find].addr);printf(修改成功\n);} 测试通讯录功能test.c //#define _CRT_SECURE_NO_WARNINGS #includeSeqList.h #includeContact.h int main() {//SL sl;//SLInit(sl);//SLPushBack(sl, 0);//SLPushBack(sl, 1);//SLPushBack(sl, 2);//SLPushBack(sl, 3);//SLPushFront(sl, 3); // SLPushFront(sl, 4);//SLPopBack(sl); // SLPopFront(sl);// SLInsert(sl, 3, 99);//SLErase(sl, 1);/*SLFind(sl, 2);SLPrint(sl);int find SLFind(sl, 2);if (find 0){printf(没有找到\n);}else{printf(找到了该数据下标是%d\n, find);}*/Contact Con;ContactInit(Con);ContactAdd(Con);ContactAdd(Con);//ContactShow(Con);ContactDel(Con);ContactDestroy(Con);return 0; } 三.结言 今天的分享结束下次再见了同学们
http://www.w-s-a.com/news/643370/

相关文章:

  • 网站改版中su域名注册
  • 做网站有没有前途济南产品网站建设外包
  • 网站备案咨询做静态网站多少钱
  • 软件开发和网站建设一样吗太原今天最新通知
  • 网站推广如何做的表白制作网站
  • 网站风格分析免费织梦网站源码
  • 大连手机自适应网站建设织梦做音乐网站
  • 烟台网站建设优化网页设计师证
  • 手机微网站建设多少钱个人网站 wordpress
  • 做外贸是不是必须有网站wordpress网络图片
  • 赣县企业网站建设用dw做网站的基本步骤
  • 辽源网站建设微信小程序公众平台
  • 多媒体网站设计开发是指什么常宁网站建设
  • 淄博网站推广优化17岁在线观看免费高清完整版
  • 企业形象网站开发业务范畴wordpress最好最全的教程
  • 企业网站的建立意义网站首页制作网站
  • 网站制作过程内容深圳最好的活动策划公司
  • 深圳网站关键词排名查询公司网站怎么做啊
  • 微网站 制作平台广州电商聚集地
  • 建设外国商城网站网站服务器 虚拟主机
  • 天河网站建设开发电子商务公司名字大全
  • 站长推荐为何用wdcp建立网站连不上ftp
  • 云南旅行社网站开发学编程多久可以写游戏辅助
  • 推广网站的步骤网站备案号中信息有变
  • 优秀企业建站织梦能不能做门户网站
  • 广东省建设局官方网站wordpress 自动安装 插件怎么用
  • 哪类小网站容易做h5页面制作代码
  • 北京网站建设公司华网百度热搜seo
  • 小清新博客网站中山做网站公司
  • 美团做团购网站如何新建自己的网站