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

怎样做网站表白墙百度超级链

怎样做网站表白墙,百度超级链,张家港普通网站建设,做营销推广外包的网站以下代码全为本人所写,如有错误,很正常,还请指出, 目录 带哨兵位循环 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.pjxw.cn/news/25519.html

相关文章:

  • 歙县建设银行网站网页制作图片
  • 潍坊做网站联系方式seo搜索引擎优化名词解释
  • 高端定制网站设计seo点击工具
  • 手机做网站时时彩赌博今日财经新闻
  • 帮别人做网站制作电脑培训学校哪家好
  • 做网站找个人还是找公司好网络营销策划总结
  • 二级建造师挂靠seo优化6个实用技巧
  • 嘉兴cms建站模板软文范例大全100字
  • idc新人如何做自己的网站个人网站建设
  • 苏州做商城网站网站产品怎么优化
  • 减肥养生网站建设友情链接适用网站
  • 深圳西乡做网站竞价防恶意点击
  • 文秘写作网站seo英文怎么读
  • 西安哪里做网站最大互联网平台有哪些
  • 那个网站做图片好看的排名公式
  • 在哪里找人做公司网站百度惠生活商家怎么入驻
  • 天元建设集团有限公司张琥超seo优化工作有哪些
  • 沈阳商城网站建设兰州关键词快速上首页排名
  • 中国做视频网站有哪些内容宜兴网站建设
  • 设计网站的意义营销型网站建设模板
  • 网站建设视觉效果整合营销包括哪些内容
  • 向客户介绍网站建设的话本百度网址导航
  • 做网站正规公司免费的网站关键词查询工具
  • 建设嘉陵摩托车官方网站手机seo排名软件
  • 做ppt找图片的网站百度地图推广
  • 河北软件开发网站建设公司做网站推广
  • 学校网站开发图片素材seo计费系统登录
  • 页面设计排版广告开户南京seo
  • 学网站建设设计要钱吗营销策划精准营销
  • 大兴网站建设报价自己接单的平台