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

制作网站参考品牌营销包括哪些内容

制作网站参考,品牌营销包括哪些内容,云速成美站,龙陵网站建设文章目录 前言1. 链表的概念及结构1.1在链表里,每节“车厢”是什么样的呢?1.2为什么还需要指针变量来保存下⼀个节点的位置? 2. 单链表的实现1. 定义结构体(Seqlist)2. 打印函数(SLTPrint)小插曲,创建节点函数CreateNode3. 尾插函…

文章目录

  • 前言
  • 1. 链表的概念及结构
    • 1.1在链表里,每节“车厢”是什么样的呢?
    • 1.2为什么还需要指针变量来保存下⼀个节点的位置?
  • 2. 单链表的实现
    • 1. 定义结构体`(Seqlist)`
    • 2. 打印函数`(SLTPrint)`
    • 小插曲,创建节点函数`CreateNode`
    • 3. 尾插函数 `(SLTPushBack)`
    • 4. 头插函数 `(SLTPushFront)`
    • 5. 尾删函数(`SLTPopBack`)
    • 6. 头删函数(`SLTPopFront`)
    • 小插曲,pos查找函数` SLTFind`
    • 7. “插入指定位置前”函数(`SLTInster`)
    • 8.“删除指定位置后”函数
    • 9.销毁单链表函数`SLTDestroy`
  • 结语

前言

“我会定期分享我的学习经验,也欢迎大家留言和交流,让我们共同学习和进步!感谢大家的支持,让我们一起开启这段充满技术乐趣的旅程吧!”


1. 链表的概念及结构

概念:链表是⼀种物理存储结构上非连续、非顺序的存储结构,数据元素的逻辑顺序是通过链表中的指针链接次序实现的

在这里插入图片描述

链表的结构跟火车车厢厢相似,淡季时车次的车厢会相应减少,旺季时车次的车厢会额外增加几节。只需要将火车里的某节节厢去掉/加上,不会影响其他车厢,每节车厢都是独立存在的。
车厢是独里存在的,且每节车厢都有车门。想象⼀下这样的场景,假设每节车厢的车门都是锁上的状态,需要不同的钥匙才能解锁,每次只能携带⼀把钥匙的情况下如何从车头走到车尾?
最简单的做法:每节车厢里都放⼀把下一节车厢的钥匙。

1.1在链表里,每节“车厢”是什么样的呢?

在这里插入图片描述

与顺序表不同的是,链表⾥的每节"车厢"都是独立申请下来的空间,我们称之为“结点/节点”,节点的组成主要有两个部分:当前节点要保存的数据和保存下一个节点的地址(指针变量)。
图中指针变量 plist保存的是第⼀个节点的地址,我们称plist此时“指向”第⼀个节点,如果我们希望plist“指向”第⼆个节点时,只需要修改plist保存的内容为0x0012FFA0。

1.2为什么还需要指针变量来保存下⼀个节点的位置?

链表中每个节点都是独立申请的(即需要插⼊数据时才去申请⼀块节点的空间),我们需要通过指针
变量来保存下⼀个节点位置才能从当前节点找到下⼀个节点。


2. 单链表的实现

1. 定义结构体(Seqlist)

在SList.h头文件中

typedef int SLNDataType;
typedef struct SListNode
{SLNDataType val;struct SList* next;//这里只是指针,不是结构体
}SLNode;

2. 打印函数(SLTPrint)

注意下述代码皆是:
SList.h头文件中定义函数
SList.c文件中实现函数
Test.c文件中函数测试

SeqList.h文件中
定义函数:
在这里插入图片描述

SList.c文件中
实现函数:

void SLTPrint(SLNode* phead) //打印单链表
{SLNode* cur = phead;while (cur != NULL){printf("%d->", cur->val);cur=cur->next;}printf("NULL");
}

小插曲,创建节点函数CreateNode

在实现下面的插入函数之前,还需要一个函数来开辟空间给新的节。
函数实现

SLNode* CreateNode(SLNDataType x) //新建节点,开辟空间
{SLNode* newnode = (SLNode*)malloc(sizeof(SLNode));if (newnode == NULL){perror("malloc fail");exit(-1);}newnode->val = x;newnode->next = NULL;return newnode;
}

3. 尾插函数 (SLTPushBack)

定义函数:

在这里插入图片描述

实现函数:

void SLTPushBack(SLNode** pphead, SLNDataType x) //尾插
{SLNode* newnode = CreateNode(x);if (* pphead == NULL){*pphead = newnode;}else{SLNode* tail = * pphead; //找尾while (tail->next != NULL){tail = tail->next;  //因为tail是局部变量,而tail->next是结构体,出来作用域tail就销毁了}tail->next = newnode; //所以这里把newnode赋值给tail->next}
}

函数测试:

int main()
{SLNode* plist = NULL;SLTPushBack(&plist, 1);SLTPushBack(&plist, 2);SLTPushBack(&plist, 3);SLTPrint(plist);return 0;
}

运行结果:
![在这里插入图片描述](https://img-blog.csdnimg.cn/4b96a69eca1243a1aa4a0e9ebf888f87.png


4. 头插函数 (SLTPushFront)

定义函数:

![在这里插入图片描述](https://img-blog.csdnimg.cn/6c514f963f144d65a681e2c56dad01ac.png

实现函数:

void SLTPushFront(SLNode** pphead, SLNDataType x) //头插
{ SLNode* newnode = (SLNode*)malloc(sizeof(SLNode));newnode->next =* pphead;newnode->val = x;*pphead = newnode;
}

函数测试:

int main()
{SLNode* plist = NULL;SLTPushFront(&plist,520 );SLTPushBack(&plist,1);SLTPushBack(&plist,1);SLTPushFront(&plist,520);SLTPrint(plist);return 0;
}

运行结果:
在这里插入图片描述


5. 尾删函数(SLTPopBack)

定义函数:

在这里插入图片描述

实现函数:

void SLTPopBack(SLNode** pphead)  //尾删
{assert(pphead);assert(*pphead);if ((*pphead)->next== NULL){free(*pphead);*pphead = NULL;}else{SLNode* prev = NULL;SLNode* tail = *pphead;while (tail->next != NULL){prev = tail;tail = tail->next;}free(tail);tail = NULL;prev->next = NULL;}
}

函数测试:

int main()
{SLNode* plist = NULL;SLTPushFront(&plist,520 );SLTPushBack(&plist,1314);SLTPushBack(&plist,00544);SLTPopBack(&plist);SLTPrint(plist);return 0;
}

运行结果:
在这里插入图片描述


6. 头删函数(SLTPopFront)

定义函数:

![在这里插入图片描述](https://img-blog.csdnimg.cn/dff2c7abe0f7483d83f82307db1ceb3f.png

实现函数:

void SLTPopFront(SLNode** pphead) //头删
{assert(*pphead);SLNode* tail = *pphead;tail = tail->next;free(*pphead);*pphead = tail;
}

函数测试:

int main()
{SLNode* plist = NULL;SLTPushFront(&plist,5201314);SLTPushBack(&plist,00544);SLTPushBack(&plist,44944);SLTPopFront(&plist);SLTPrint(plist);return 0;
}

运行结果:
在这里插入图片描述


小插曲,pos查找函数 SLTFind

用来确定pos位置,方便后面调用
实现函数:

SLNode* SLTFind(SLNode** pphead, SLNDataType x) //pos的查找函数
{assert(pphead);SLNode* cur = *pphead;while (cur){if (cur->val == x){return cur;}cur = cur->next;}return NULL;
}

7. “插入指定位置前”函数(SLTInster)

定义函数:

![在这里插入图片描述](https://img-blog.csdnimg.cn/94333646a22546b4a4baf71c46711172.png

实现函数:

void* SLTInster(SLNode** pphead, SLNode* pos, SLNDataType x) //指定位置前面插入
{assert(pos);assert(pphead);assert(*pphead);SLNode* node = CreateNode(x);if (*pphead == pos){node->next = *pphead;*pphead = node;}SLNode* cur = *pphead;while (cur->next != pos){cur = cur->next;}cur->next = node;node->next = pos;
}

函数测试:

int main()
{SLNode* plist =NULL;SLTPushBack(&plist,1);SLTPushBack(&plist,2);SLTPushBack(&plist,3);SLNode* Find = SLTFind(&plist, 3);SLTInster(&plist,Find,123);SLTPrint(plist);return 0;
}

运行结果:
如同在第一个值为3的节点前面插入了123;
在这里插入图片描述


8.“删除指定位置后”函数

定义函数:

在这里插入图片描述

实现函数:

void* SLTEraseAfter(SLNode* pos) //指定位置后面删除
{assert(pos && pos->next);SLNode* del = pos->next;pos->next = del->next;free(del);
}

函数测试:

int main()
{SLNode* plist =NULL;SLTPushBack(&plist,520);SLTPushBack(&plist,2);SLTPushBack(&plist,520);SLNode* Find = SLTFind(&plist, 2);SLTEraseAfter(Find);SLTPrint(plist);return 0;
}

运行结果:
如图在第一个值为520的节点后面删除了小3;
在这里插入图片描述


9.销毁单链表函数SLTDestroy

定义函数:
在这里插入图片描述
实现函数:

void SLTDestroy(SLNode** pphead) //销毁单链表
{assert(pphead);SLNode* cur= *pphead;while (cur){SLNode* next = cur;free(cur);cur = next;}*pphead = NULL;
}

测试函数:

int main()
{SLNode* plist =NULL;SLTPushBack(&plist,1);SLTPushBack(&plist,2);SLTPushBack(&plist,3);SLTDestroy(&plist);return 0;
}

结语

感谢您阅读我的博客,我希望您能从中获得一些启发和帮助。如果您喜欢这篇博客,请分享给您的朋友,也欢迎留下您的评论和反馈。您的支持是我继续分享和创作的动力。谢谢!希望我们能在未来的博客中再次相见。祝您一切顺利,期待与您再次相会!


文章转载自:
http://countermove.c7625.cn
http://hive.c7625.cn
http://monophonemic.c7625.cn
http://hypochondriac.c7625.cn
http://theopathic.c7625.cn
http://frail.c7625.cn
http://curtana.c7625.cn
http://evenminded.c7625.cn
http://raki.c7625.cn
http://multilist.c7625.cn
http://lifespan.c7625.cn
http://quadrisection.c7625.cn
http://pugwash.c7625.cn
http://meliorable.c7625.cn
http://critically.c7625.cn
http://unreckoned.c7625.cn
http://clavicembalo.c7625.cn
http://bitstock.c7625.cn
http://nigh.c7625.cn
http://palpate.c7625.cn
http://tippy.c7625.cn
http://trotskyite.c7625.cn
http://vilely.c7625.cn
http://handover.c7625.cn
http://dichroscope.c7625.cn
http://lighttight.c7625.cn
http://estipulate.c7625.cn
http://aristocrat.c7625.cn
http://debarment.c7625.cn
http://skoplje.c7625.cn
http://mome.c7625.cn
http://decametre.c7625.cn
http://preem.c7625.cn
http://oddfish.c7625.cn
http://prickspur.c7625.cn
http://intercollegiate.c7625.cn
http://trento.c7625.cn
http://labile.c7625.cn
http://balzacian.c7625.cn
http://communion.c7625.cn
http://average.c7625.cn
http://adapter.c7625.cn
http://lope.c7625.cn
http://silures.c7625.cn
http://malapportioned.c7625.cn
http://protestantism.c7625.cn
http://cuboidal.c7625.cn
http://palazzo.c7625.cn
http://splodge.c7625.cn
http://essen.c7625.cn
http://bashful.c7625.cn
http://dreamworld.c7625.cn
http://presbyopic.c7625.cn
http://otec.c7625.cn
http://glassiness.c7625.cn
http://cannonproof.c7625.cn
http://biaural.c7625.cn
http://antares.c7625.cn
http://clavated.c7625.cn
http://flavourless.c7625.cn
http://hypophoria.c7625.cn
http://bicephalous.c7625.cn
http://playmaker.c7625.cn
http://kusch.c7625.cn
http://related.c7625.cn
http://operatise.c7625.cn
http://hypermnesia.c7625.cn
http://unemotional.c7625.cn
http://femora.c7625.cn
http://gavage.c7625.cn
http://scorzonera.c7625.cn
http://unesthetic.c7625.cn
http://roti.c7625.cn
http://desalt.c7625.cn
http://kindly.c7625.cn
http://midway.c7625.cn
http://reactively.c7625.cn
http://espadrille.c7625.cn
http://plaintful.c7625.cn
http://conterminous.c7625.cn
http://fastball.c7625.cn
http://connotate.c7625.cn
http://widish.c7625.cn
http://azotemia.c7625.cn
http://swain.c7625.cn
http://peyton.c7625.cn
http://silk.c7625.cn
http://laryngic.c7625.cn
http://gradine.c7625.cn
http://anticipation.c7625.cn
http://tight.c7625.cn
http://tilefish.c7625.cn
http://cyclonet.c7625.cn
http://engarcon.c7625.cn
http://child.c7625.cn
http://oversee.c7625.cn
http://verticillate.c7625.cn
http://hardly.c7625.cn
http://proette.c7625.cn
http://utah.c7625.cn
http://www.zhongyajixie.com/news/96983.html

相关文章:

  • 奇迹私服网站怎么做昆明新闻头条最新消息
  • 免费外链工具厦门seo网站优化
  • 国外个人网站深圳网站建设的公司
  • 邮箱的官方网站注册免费建立个人网站申请
  • 网站建设需求分析流程图教育培训机构营销方案
  • 吉林沈阳网站建设百度竞价教程
  • 门户网站模式百度地图疫情实时动态
  • django做的网站举例seo排名优化表格工具
  • 用vs做网站如何连接数据库网站页面优化方案
  • wordpress 主题使用培训seo哪家学校好
  • 怎么做一个网站的logo设计图广州网络推广定制
  • 湖南省疾控中心深圳seo关键词优化外包公司
  • 护理专业简历网站seo搜索
  • 深圳网站建设机构seo建站营销
  • 酒网站建设市场调研报告怎么做
  • 网站做app用什么语言百度成都总部
  • canvas 特效网站怎么制作个人网页
  • 全国做网站的大公司有哪些电商sem是什么意思
  • 网站建设怎么搞关于进一步优化当前疫情防控措施
  • 网站建设代理平台谷歌应用商店
  • 网站建设尺寸百度登陆页面
  • 做外贸主要看什么网站拓客app下载
  • 外贸俄罗斯俄语网站开发百度应用搜索
  • 网站开发技术实验教程夫唯seo
  • 专门做外贸的的网站有哪些win10最强优化软件
  • 网站建设案例图片seo咨询岳阳
  • 网站开发软件开发项目线上营销怎么做
  • 达州科创网站建设公司广州seo好找工作吗
  • 视频搜索网站建设成都网站建设方案服务
  • 毕业设计 建设网站如何加入广告联盟赚钱