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

腾讯 网站建设/百度人工投诉电话是多少

腾讯 网站建设,百度人工投诉电话是多少,使用php如何做购物网站,流动性管理以下代码全为本人所写,如有错误,很正常,还请指出, 目录 带哨兵位循环 test.c DLList.c DLList.h 不带哨兵位不循环 test.c DLList.c DLList.h 带哨兵位循环 test.c #define _CRT_SECURE_NO_WARNINGS#include"DLlist.h&…

 以下代码全为本人所写,如有错误,很正常,还请指出,

目录

带哨兵位循环

 test.c

DLList.c 

 DLList.h

 不带哨兵位不循环

test.c 

 DLList.c

 DLList.h


带哨兵位循环

 test.c

#define  _CRT_SECURE_NO_WARNINGS#include"DLlist.h"int main()
{//初始化链表DL* DLList = DLListInit();//因为带哨兵位,不需要修改头节点,修改的是头节点指向的结构体的内容//传值就行,传的是DLList这个指针存的地址SLPushBack(DLList,8);SLPushFront(DLList, 5);SLPushFront(DLList, 6);SLPushBack(DLList,7);SLprint(DLList);//6->5->8->7SLPopFrpnt(DLList);SLPopBack(DLList);SLPushBack(DLList, 7);SLprint(DLList);//5->8->7DL* pos=SLFind(DLList,8);SLInsertBack(DLList,pos,9);//后插    5->8->9->7SLprint(DLList);pos = SLFind(DLList, 8);SLInsertFront(DLList, pos, 10);  //前插  5->10->8->9->7SLprint(DLList);SLErase(DLList,pos);//删除  5->10->9->7SLprint(DLList);DListDestory(DLList);return 0;
}

DLList.c 

#define  _CRT_SECURE_NO_WARNINGS#include"DLlist.h"DL* BuyDLNode()
{DL* newcode = (DL*)malloc(sizeof(DL));return newcode;//返回的是这个指针存的地址
}DL* DLListInit()
{DL* newcode = BuyDLNode();//存的是malloc开辟空间的地址newcode->val = -1;newcode->next = newcode;newcode->prev = newcode;return newcode;
}void SLPushFront(DL* pphead, SLdatatype x)
{assert(pphead);DL* newcode = BuyDLNode();newcode->prev = pphead;newcode->next = pphead->next;newcode->val = x;DL* first = pphead->next;pphead->next = newcode;first->prev = newcode;
}void SLPushBack(DL* pphead, SLdatatype x)
{assert(pphead);DL* newcode = BuyDLNode();newcode->next = pphead;newcode->prev = pphead->prev;newcode->val = x;DL* end = pphead->prev;pphead->prev = newcode;end->next = newcode;
}void SLPopFrpnt(DL* pphead)
{assert(pphead);DL* first = pphead->next;DL* second = pphead->next->next;free(first);pphead->next = second;second->prev = pphead;
}void SLPopBack(DL* pphead)
{assert(pphead);DL* end = pphead->prev;DL* end_second = pphead->prev->prev;free(end);pphead->prev = end_second;end_second->next = pphead;
}DL* SLFind(DL* pphead, SLdatatype x)
{assert(pphead);DL* tail = pphead->next;while (tail->val != x){tail = tail->next;if (tail == pphead){printf("该链表内不存在该数据\n");return NULL;}}return tail;
}void SLInsertBack(DL* pphead, DL* pos, SLdatatype x)
{assert(pphead);assert(pos);DL* tail = pphead->next;while (tail != pos)//tail找到对应的节点   后插{tail = tail->next;}DL* newcode = BuyDLNode();newcode->val = x;newcode->next = tail->next;newcode->prev = tail;DL* Back = tail->next;Back->prev = newcode;tail->next = newcode;
}void SLInsertFront(DL* pphead, DL* pos, SLdatatype x)
{assert(pphead);assert(pos);DL* tail = pphead->next;while (tail != pos)//tail找到对应的节点   前插{tail = tail->next;}DL* newcode = BuyDLNode();newcode->val = x;newcode->next = tail;newcode->prev = tail->prev;DL* Front = tail->prev;Front->next = newcode;tail->prev = newcode;
}void SLErase(DL* pphead, DL* pos)
{assert(pphead);assert(pos);DL* tail = pphead->next;while (tail != pos)//tail找到对应的节点  要删除的节点{tail = tail->next;}DL* Front = tail->prev;DL* Back = tail->next;free(tail);Front->next = Back;Back->prev = Front;
}void SLprint(DL* pphead)
{DL* tail = pphead->next;printf("Sentinel->");while (tail != pphead){printf("%d->", tail->val);tail = tail->next;}printf("NULL\n");
}void DListDestory(DL* pphead)
{assert(pphead);DL* tail = pphead->next;while (tail != pphead){//先保存DL* tmp = tail->next;free(tail);tail = tmp;}free(pphead);
}

 DLList.h

#define  _CRT_SECURE_NO_WARNINGS#include<stdio.h>
#include<assert.h>
#include<string.h>
#include<stdlib.h>typedef int SLdatatype;typedef struct ListNode
{SLdatatype val;struct ListNode* next;struct ListNode* prev;
}DL;DL* BuyDLNode();DL* DLListInit();void SLPushFront(DL* pphead, SLdatatype x);void SLPushBack(DL* pphead, SLdatatype x);void SLPopFrpnt(DL* pphead);void SLPopBack(DL* pphead);DL* SLFind(DL* pphead, SLdatatype x);void SLInsertBack(DL* pphead, DL* pos, SLdatatype x);void SLInsertFront(DL* pphead, DL* pos, SLdatatype x);void SLErase(DL* pphead, DL* pos);void SLprint(DL* pphead);void DListDestory(DL* pphead);

 不带哨兵位不循环

test.c 

#define  _CRT_SECURE_NO_WARNINGS#include"DLList.h"int main()
{DL* DLList = NULL;DLPushFront(&DLList, 6);DLPushFront(&DLList, 5);DLPushBack(&DLList, 7);DLPushBack(&DLList, 8);DLprint(DLList);DLPopFront(&DLList);DLprint(DLList);DLPopBack(&DLList);DLprint(DLList);DLPushBack(&DLList, 10);DLPushBack(&DLList, 11);DLprint(DLList);DL* pos= DListFind(DLList, 10);DLEarse(&DLList, pos);DLprint(DLList);pos = DListFind(DLList, 7);DLInsertBack(&DLList, pos, 12);//任意位置后插DLprint(DLList);DLInsertFront(&DLList, pos, 13);//任意位置前插DLprint(DLList);pos = DListFind(DLList, 6);Modify(&DLList,pos,20);DLprint(DLList);//释放链表DListDestory(&DLList);return 0;
}

 DLList.c

#define  _CRT_SECURE_NO_WARNINGS#include"DLList.h"void DLPushFront(DL** pphead, SLdatatype x)
{assert(pphead);DL* newcode = (DL*)malloc(sizeof(DL));DL* tail = *pphead;if (newcode == NULL){perror("malloc error\n");return;}//if (*pphead == NULL)//{//赋值newcode->val = x;newcode->prev = NULL;newcode->next = *pphead;//更换头节点*pphead = newcode;return;//	}return;
}void DLPushBack(DL** pphead, SLdatatype x)
{assert(pphead);DL* newcode = (DL*)malloc(sizeof(DL));if (newcode == NULL){perror("malloc error\n");return;}if (*pphead == NULL){*pphead = newcode;(*pphead)->val = x;(*pphead)->next = NULL;(*pphead)->next = NULL;return;}DL* tail = *pphead;while (tail->next)//找到最后一个节点{tail = tail->next;}tail->next = newcode;newcode->val = x;newcode->prev = tail;newcode->next = NULL;return;
}void DLPopFront(DL** pphead)
{assert(pphead);assert(*pphead);DL* tail = *pphead;*pphead = (*pphead)->next;//释放第一个节点free(tail);//更换(*pphead)->prev = NULL;return;
}void DLPopBack(DL** pphead)
{assert(pphead);assert(*pphead);DL* tail = *pphead;//而且还要找到倒数第二个节点,//改变其的next  NULL//但如果只有一个节点if (tail->next == NULL){free(pphead);
//		*pphead = NULL;return;}while (tail->next->next)//找到最后二个节点{tail = tail->next;}DL* back = tail->next;//找到最后一个节点free(back);tail->next = NULL;//修改倒数第二个节点return;
}DL* DListFind(DL* plist, SLdatatype x)
{assert(plist);DL* tail = plist;while (tail){if (tail->val == x)//判断{return tail;}//迭代tail = tail->next;}printf("该信息在该链表内不存在\n");return NULL;
}void DLEarse(DL** pphead, DL* pos)
{assert(pphead);assert(*pphead);assert(pos);DL* tail = *pphead;//但是还需要找到下一个节点  修改prev   改为上一节点//上一节点   修改next   改为下一节点while (tail != pos)//找到对应要删除的节点{tail = tail->next;}if (tail->next==NULL)//尾节点{DLPopBack(pphead);return;}else if (tail->prev == NULL)//头节点{DLPopFront(pphead);return;}DL* Front = tail->prev;DL* Back = tail->next;free(tail);Front->next = Back;Back->prev = Front;return;
}void DLInsertBack(DL** pphead, DL* pos, SLdatatype x)
{assert(pphead);assert(pos);DL* tail = *pphead;while (tail != pos)//找到对应节点{tail = tail->next;}if (tail->next == NULL)//尾节点{DLPushBack(pphead,x);return;}else if (tail->prev == NULL)//头节点{DLPushFront(pphead,x);return;}//先malloc//修改该节点的next  指向新添加的节点//修改本来节点的下一个节点   修改prev  改为指向新添加的节点DL* newcode = (DL*)malloc(sizeof(DL));if (newcode == NULL){perror("malloc error\n");}newcode->val = x;newcode->next = tail->next;newcode->prev = tail;DL* Back = tail->next;//原本链表下一个节点tail->next = newcode;//修改原本节点的next指向新添加的Back->prev = newcode;//修改原本节点下一个节点的prevreturn;
}void DLInsertFront(DL** pphead, DL* pos, SLdatatype x)//前插
{assert(pphead);assert(pos);DL* tail = *pphead;while (tail != pos)//找到对应节点{tail = tail->next;}if (tail->next == NULL)//尾节点{DLPushBack(pphead, x);return;}else if (tail->prev == NULL)//头节点{DLPushFront(pphead, x);return;}//先malloc//修改该节点的next  指向新添加的节点//修改本来节点的下一个节点   修改prev  改为指向新添加的节点DL* newcode = (DL*)malloc(sizeof(DL));if (newcode == NULL){perror("malloc error\n");}newcode->val = x;newcode->next = tail;newcode->prev = tail->prev;DL* Front = tail->prev;//原本链表下一个节点tail->prev = newcode;//修改原本节点的prev指向新添加的Front->next = newcode;//修改原本节点上一个节点的nextreturn;
}void Modify(DL** pphead, DL* pos, SLdatatype x)
{assert(pphead);assert(pos);DL* tail = *pphead;while (tail != pos)//找到对应节点{tail = tail->next;}tail->val = x;return;
}void DLprint(DL* pphead)
{DL* tail = pphead;while (tail != NULL){printf("%d->", tail->val);tail = tail->next;}printf("NULL\n");
}void DListDestory(DL** pphead)
{DL* tmp = *pphead;while (*pphead != NULL){//先保存该节点指向的地址tmp = *pphead;*pphead = (*pphead)->next;free(tmp);tmp = NULL;}return;
}

 DLList.h

#define  _CRT_SECURE_NO_WARNINGS#include<stdio.h>
#include<assert.h>
#include<string.h>
#include<stdlib.h>typedef int SLdatatype;typedef struct ListNode
{SLdatatype val;struct ListNode* next;struct ListNode* prev;
}DL;void DLPushFront(DL** pphead, SLdatatype x);void DLPushBack(DL** pphead, SLdatatype x);void DLPopFront(DL** pphead);void DLPopBack(DL** pphead);DL* DListFind(DL* plist, SLdatatype x);void DLEarse(DL** pphead,DL* pos);void DLInsertBack(DL** pphead, DL* pos, SLdatatype x);void DLInsertFront(DL** pphead, DL* pos, SLdatatype x);void Modify(DL** pphead, DL* pos, SLdatatype x);void DLprint(DL* pphead);void DListDestory(DL** pphead);

http://www.jmfq.cn/news/5347999.html

相关文章:

  • 高青县住房和城乡建设局网站/1688官网入口
  • 网站建设运营计划书/广州seo搜索
  • 美丽乡村建设网站php源码/商城小程序开发哪家好
  • 宿迁市建设局网站怎么投诉/seo网络营销技巧
  • 政府网站建设企划书/适合口碑营销的产品
  • 网站建设开发电销话术/免费合作推广
  • 万维建设网站/品牌营销策划十大要点
  • 网站建设服务合同范本/长春网站推广排名
  • 山东公路建设集团网站/无屏蔽搜索引擎
  • 徐州贾汪区建设局网站/怎么有自己的网站
  • 浅谈博物馆网站建设的意义/我想做网络推广找谁
  • 沧源网站建设/百度搜索引擎怎么做
  • 做文化建设的网站/谷歌搜索入口中文
  • 怎么建设网站容易被百度抓取/百度app登录
  • 网站建设中 翻译/最有效的推广学校的方式
  • 电子商务企业网站建设前期规划方案/网络零售的优势有哪些
  • 盐城建设网站/链接推广平台
  • 福建大舟建设集团有限公司 网站/青岛网站建设制作推广
  • 网站建设 部署与发布视频教程/软文是什么
  • 慈溪建设集团网站/今日头条网站推广
  • 档案信息网站建设的意义/百度安装免费下载
  • 石家庄知名网站建设/企业推广公司
  • 政府门户网站建设情况简介/江门seo外包公司
  • 外贸企业网站建设公司价格/最新旅游热点
  • 网站建设汇报/今日头条收录入口
  • 网站建设 乐达云创/百度关键词优化培训
  • 小米网站建设项目书/seo关键词分类
  • 网站建设需要会什么软件/电商代运营
  • 渭南市网站建设/网络培训班
  • 余杭区高端网站建设/郑州seo优化外包