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

网站流量分析方法网站开发模板图片

网站流量分析方法,网站开发模板图片,地方门户网站开发方案,微信第三方网站开发教程CSDN主页#xff1a;醋溜马桶圈_C语言进阶,初始C语言,数据结构-CSDN博客 Gitee主页#xff1a;mnxcc (mnxcc) - Gitee.com 专栏#xff1a;数据结构_醋溜马桶圈的博客-CSDN博客 目录 1.认识单链表 2.创建单链表 3.单链表的操作 3.1打印单链表 3.2开辟新空间 3.3尾插 3.4头插… CSDN主页醋溜马桶圈_C语言进阶,初始C语言,数据结构-CSDN博客 Gitee主页mnxcc (mnxcc) - Gitee.com 专栏数据结构_醋溜马桶圈的博客-CSDN博客 目录 1.认识单链表 2.创建单链表 3.单链表的操作 3.1打印单链表 3.2开辟新空间 3.3尾插 3.4头插 3.5尾删 3.6头删 3.7查找 3.8在pos前面插入 3.9删除pos位置 3.10销毁 3.11在pos位置之后插入  3.12删除pos位置之后的值 4.总代码 SList.h SList.c test.c 我们之前学习了顺序表的有关知识顺序表存在下面的问题 尾插效率还不错头插或中间插入删除需要挪动数据效率低满了以后只能扩容扩容是有一定的消耗的扩容一般存在一定的空间浪费 1.认识单链表 这篇文章我们来认识一下单链表 如果想要插入一个结点就不需要挪动数据了改指针的指向就可以了 同样我们删除结点直接将前一个结点的指针指向后一个结点就可以了 首先我们还是从工程的角度去考虑创建SList.h SList.c test.c三个文件 SList.h放置函数的声明 SList.c放置函数的定义 test.c进行测试  2.创建单链表 3.单链表的操作 3.1打印单链表 //打印单链表 //尽量不要动phead void SLTPrint(SLNode* phead) {SLNode* cur phead;while (cur ! NULL){printf(%d-, cur-val);cur cur-next;}printf(NULL\n); } 3.2开辟新空间 //开辟新空间 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.3尾插 //尾插 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-next newnode;} } 3.4头插 //头插 void SLTPushFront(SLNode** pphead, SLNDataType x) {SLNode* newnode CreateNode(x);newnode-next *pphead;*pphead newnode; } 3.5尾删 //尾删 void SLTPopBack(SLNode** 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);prev-next NULL;} } 3.6头删 //头删 void SLTPopFront(SLNode** pphead) {assert(*pphead);SLNode* tmp *pphead;*pphead (*pphead)-next;free(tmp); } 3.7查找 //查找 SLNode* SLTFind(SLNode* phead, SLNDataType x) {SLNode* cur phead;while (cur){if (cur-val x){return cur;}else{cur cur-next;}}return NULL; } 3.8在pos前面插入 //在pos前面插入 void SLTInsert(SLNode** pphead, SLNode* pos, SLNDataType x) {assert(pphead);assert(pos);assert(*pphead);//assert((!pos !(*pphead)) || (pos (*pphead)));if (*pphead pos){SLTPushFront(pphead, x);}else{SLNode* prev *pphead;while (prev-next ! pos){prev prev-next;}SLNode* newnode CreateNode(x);prev-next newnode;newnode-next pos;} } 3.9删除pos位置 //删除pos位置 void SLTErase(SLNode** pphead, SLNode* pos) {assert(pphead);assert(pos);assert(*pphead);if (*pphead pos){SLTPopFront(pphead);}else{SLNode* prev *pphead;while (prev-next ! pos){prev prev-next;}prev-next pos-next;free(pos);pos NULL;} } 3.10销毁 //销毁 void SLTDestroy(SLNode** pphead) {assert(pphead);SLNode* cur *pphead;while (cur-next ! NULL){SLNode* next cur-next;free(cur);cur next;}*pphead NULL; } 3.11在pos位置之后插入 // 单链表在pos位置之后插入x void SLTInsertAfter(SLNode* pos, SLNDataType x) {SLNode* newnode CreateNode(x);newnode-next pos-next;pos-next newnode; } 3.12删除pos位置之后的值 // 单链表删除pos位置之后的值 void SLTEraseAfter(SLNode* pos) {assert(pos-next ! NULL);pos-next pos-next-next;free(pos-next);pos-next NULL; } 4.总代码 SList.h #pragma once #include stdio.h #include stdlib.h #include assert.h //创建单链表 typedef int SLNDataType; typedef struct SLNode {SLNDataType val;struct SLNode* next; }SLNode;//打印单链表 //尽量不要动phead void SLTPrint(SLNode* phead); //开辟新空间 SLNode* CreateNode(SLNDataType x);//尾插 void SLTPushBack(SLNode** pphead, SLNDataType x); //头插 void SLTPushFront(SLNode** pphead, SLNDataType x); //尾删 void SLTPopBack(SLNode** pphead); //头删 void SLTPopFront(SLNode** pphead);//查找 SLNode* SLTFind(SLNode* phead, SLNDataType x); //在pos前面插入 void SLTInsert(SLNode** pphead, SLNode* pos, SLNDataType x); //删除pos位置 void SLTErase(SLNode** pphead, SLNode* pos); // 单链表在pos位置之后插入x void SLTInsertAfter(SLNode* pos, SLNDataType x); // 单链表删除pos位置之后的值 void SLTEraseAfter(SLNode* pos);//销毁 void SLTDestroy(SLNode** pphead);SList.c #define _CRT_SECURE_NO_WARNINGS 1 #includeSList.h //打印单链表 //尽量不要动phead void SLTPrint(SLNode* phead) {SLNode* cur phead;while (cur ! NULL){printf(%d-, cur-val);cur cur-next;}printf(NULL\n); } //开辟新空间 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; } //尾插 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-next newnode;} } //头插 void SLTPushFront(SLNode** pphead, SLNDataType x) {SLNode* newnode CreateNode(x);newnode-next *pphead;*pphead newnode; } //尾删 void SLTPopBack(SLNode** 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);prev-next NULL;} } //头删 void SLTPopFront(SLNode** pphead) {assert(*pphead);SLNode* tmp *pphead;*pphead (*pphead)-next;free(tmp); } //查找 SLNode* SLTFind(SLNode* phead, SLNDataType x) {SLNode* cur phead;while (cur){if (cur-val x){return cur;}else{cur cur-next;}}return NULL; } //在pos前面插入 void SLTInsert(SLNode** pphead, SLNode* pos, SLNDataType x) {assert(pphead);assert(pos);assert(*pphead);//assert((!pos !(*pphead)) || (pos (*pphead)));if (*pphead pos){SLTPushFront(pphead, x);}else{SLNode* prev *pphead;while (prev-next ! pos){prev prev-next;}SLNode* newnode CreateNode(x);prev-next newnode;newnode-next pos;} } //删除pos位置 void SLTErase(SLNode** pphead, SLNode* pos) {assert(pphead);assert(pos);assert(*pphead);if (*pphead pos){SLTPopFront(pphead);}else{SLNode* prev *pphead;while (prev-next ! pos){prev prev-next;}prev-next pos-next;free(pos);pos NULL;} } // 单链表在pos位置之后插入x void SLTInsertAfter(SLNode* pos, SLNDataType x) {SLNode* newnode CreateNode(x);newnode-next pos-next;pos-next newnode; } // 单链表删除pos位置之后的值 void SLTEraseAfter(SLNode* pos) {assert(pos-next ! NULL);pos-next pos-next-next;free(pos-next);pos-next NULL; } //销毁 void SLTDestroy(SLNode** pphead) {assert(pphead);SLNode* cur *pphead;while (cur-next ! NULL){SLNode* next cur-next;free(cur);cur next;}*pphead NULL; }test.c #define _CRT_SECURE_NO_WARNINGS 1 #include SList.h int main() {SLNode* plist NULL;SLTPushBack(plist, 1);SLTPushBack(plist, 2);SLTPushBack(plist, 3);SLTPushBack(plist, 4);SLTPushFront(plist, 5);SLTPrint(plist);SLTPopBack(plist);SLTPrint(plist);SLTPopFront(plist);SLTPrint(plist);SLNode* pos SLTFind(plist, 2);SLTInsert(plist, pos, 0);SLTPrint(plist);/*SLTErase(plist, pos);SLTPrint(plist);*/SLTInsertAfter(pos, 0);SLTPrint(plist);SLTEraseAfter(pos);SLTPrint(plist);SLTDestroy(plist);return 0; }
http://www.zqtcl.cn/news/493733/

相关文章:

  • 网站建设历程wordpress国内主题排行
  • 公司网站建设及优化计划书找能做网站的
  • 网站建设方案模板下载南宁有名的网络公司
  • 本地做织梦网站做软件怎么赚钱
  • a站全称重庆大学网络教育平台
  • 美橙做过网站案例好文案网站
  • 鞍山商城网站建设国外代理ip
  • 东莞网站设计风格wordpress不能启动怎么解决
  • 社交网站制作临海建设局网站导航
  • 合肥需要做网站的公司佛山网站制作的公司
  • 哪里有做网站平台建设网站如何盈利
  • dw网站制作素材单人做网站需要掌握哪些知识
  • 网络推广产品公司做移动网站优化首
  • 网站建设dqcx广告网络用语
  • 烟台网站建设首推企汇互联见效付款手机网站宽度自适应
  • 网站建设小程序湖南wordpress插件刷不出来
  • 中国建设银行网站首页joy荣添创意网站建设
  • 市场营销网站网站开发技术项目说明书
  • 销售网站开发的背景wordpress虚线框可序列
  • 免费响应式网站深圳关键词优化
  • 网站宣传模式做微视频的网站
  • 网站改版后的内容福建 网站建设
  • 网站的文件夹企业邮箱在哪查看
  • 开了360网站卫士ssl如何做301深圳制作网站开发费用
  • 在哪里做马可波罗网站公众号自己做电影网站
  • 网站建设音乐插件怎么弄陕西城乡建设部网站首页
  • 全国免费自学网站打开百度网站首页
  • 国外网站开发公司晋江论坛网
  • 问卷调查网站个人网站源码免费下载
  • 网站备案信息核验单填写建设企业网站价钱