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

网站icp备案号怎么查炫酷的网站设计

网站icp备案号怎么查,炫酷的网站设计,wordpress需要配置文件,android 创建wordpress本文主要探讨单链表与双链表相关知识。 linux内核链表(include/linux/list.h) 内核链表中纯链表封装,纯链表的各种操作函数(节点创建、插入、删除、遍历),纯链表内嵌在驱动结构体中,实现驱动的创建、插入、删除、遍历等 单链表 单链表链表头插…

本文主要探讨单链表与双链表相关知识。

linux内核链表(include/linux/list.h)
        内核链表中纯链表封装,纯链表的各种操作函数(节点创建、插入、删除、遍历······),纯链表内嵌在驱动结构体中,实现驱动的创建、插入、删除、遍历等

单链表 

        单链表链表头插入节点,尾插入节点,删除节点,逆序

代码示例:

#include <stdio.h>
#include <stdlib.h>struct node
{int data;struct node *next;
};//创建节点
struct node * create_node(int data)
{struct node *p = (struct node *)malloc(sizeof(struct node));if(p == NULL){printf("malloc error\n");return NULL;}p->data = data;p->next = NULL;return p;
}//头部插入节点
void insert_head(struct node *phead,struct node *new)
{struct node *p = phead;if(p == NULL)exit(0);new->next = p->next;p->next = new;(phead->data)++;        //头节点存储节点数量
}//尾部插入
void insert_tail(struct node *phead,struct node *new)
{struct node *p = phead;if(p == NULL)exit(0);while(p->next != NULL){p = p->next;}p->next = new;(phead->data)++;        //头节点存储节点数量
}//遍历链表
void printf_link(struct node *phead)
{if(phead == NULL)exit(0);struct node *p = phead;printf("num of struct : %d \n",p->data);while(p->next != NULL){p = p->next;printf("struct data : %d\n",p->data);}
}//删除节点
int  delete_node(struct node *phead,int data)
{if(phead == NULL)exit(-1);struct node *p = phead;struct node *prev = NULL;while(p->next != NULL){prev = p;p = p->next;if(p->data == data){if(p->next != NULL){prev->next = p->next;   //其他节点free(p);}else{prev->next = NULL;      //尾节点free(p);}(phead->data)--;return 0;}}printf("have no data\n");return -1;
}//链表逆序
void reserve_link(struct node *phead)
{if(phead == NULL)exit(-1);struct node *p = phead->next;struct node *back = NULL;struct node *prev = NULL;if(p->next == NULL || p == NULL)        //只有一个节点,不逆序return ;while(p->next != NULL)                  //两个及两个以上节点{back = p->next;                 //保存链表的下一个节点,由于头插逆序法插入节点与后面节点断开if(p == phead->next)            //第一个节点指向NULL作为逆序首节点{p->next = NULL;}else{p->next = phead->next;}phead->next = p;p = back;}insert_head(phead,p);   //最后一个节点插入到链表,由于最后一个节点指向NULL,while判断失效(phead->data)--;        //头插最后一个节点时,默认新增一个节点
}int main()
{//创建头节点struct node *head = create_node(0);//头部插入节点insert_head(head,create_node(1));insert_head(head,create_node(2));insert_head(head,create_node(3));insert_head(head,create_node(4));insert_head(head,create_node(5));//尾部插入节点insert_tail(head,create_node(1));insert_tail(head,create_node(2));insert_tail(head,create_node(3));insert_tail(head,create_node(4));insert_tail(head,create_node(5));//遍历节点printf_link(head);//删除节点delete_node(head,5);delete_node(head,5);delete_node(head,4);//遍历节点printf_link(head);//链表逆序reserve_link(head);//遍历节点printf_link(head);return 0;
}

结果示例:

双链表

        双链表尾插入,头插入,删除节点,前向遍历,后向遍历 

代码示例:

#include <stdio.h>
#include <stdlib.h>struct node
{int data;struct node *next;struct node *prev;
};//创建节点
struct node * create_node(int data)
{struct node *p = (struct node *)malloc(sizeof(struct node));if(p == NULL){printf("malloc error\n");return NULL;}p->data = data;p->next = NULL;p->prev = NULL;return p;
}//头部插入节点
void insert_head(struct node *phead,struct node *new)
{struct node *p = phead;if(p == NULL)exit(0);new->next = p->next;if(p->next != NULL)p->next->prev = new;p->next = new;new->prev = p;(phead->data)++;        //头节点存储节点数量
}//尾部插入
void insert_tail(struct node *phead,struct node *new)
{struct node *p = phead;if(p == NULL)exit(0);while(p->next != NULL){p = p->next;}p->next = new;new->prev = p;new->next = NULL;(phead->data)++;        //头节点存储节点数量
}//后项遍历链表
void next_printf_link(struct node *phead)
{if(phead == NULL)exit(0);struct node *p = phead;printf("num of struct : %d \n",p->data);while(p->next != NULL){p = p->next;printf("struct data : %d\n",p->data);}
}//前项遍历链表
void prev_printf_link(struct node *phead)
{if(phead == NULL)exit(0);struct node *p = phead;printf("num of struct : %d \n",p->data);while(p->next != NULL){p = p->next;}while(p->prev != NULL){printf("struct data : %d\n",p->data);p = p->prev;}
}//删除节点
int  delete_node(struct node *phead,int data)
{if(phead == NULL)exit(-1);struct node *p = phead;struct node *test = NULL;while(p->next != NULL){p = p->next;if(p->data == data){if(p->next == NULL){p->prev->next = NULL;   //尾节点}else{//其他节点p->prev->next = p->next;p->next->prev = p->prev;}free(p);(phead->data)--;return 0;}}printf("have no data\n");return -1;
}int main()
{//创建头节点struct node *head = create_node(0);//头部插入节点insert_head(head,create_node(1));insert_head(head,create_node(2));insert_head(head,create_node(3));insert_head(head,create_node(4));insert_head(head,create_node(5));//尾部插入节点insert_tail(head,create_node(1));insert_tail(head,create_node(2));insert_tail(head,create_node(3));insert_tail(head,create_node(4));insert_tail(head,create_node(5));//遍历节点next_printf_link(head);//删除节点delete_node(head,2);delete_node(head,5);delete_node(head,4);//next遍历节点next_printf_link(head);//prev遍历节点prev_printf_link(head);return 0;
}

结果示例:

http://www.yayakq.cn/news/224925/

相关文章:

  • 旅游网站的广告预算怎么做应用大全网站
  • 百度网站排名哪家好那个网站做问卷好
  • 网站开发工作总结论文wordpress获得留言
  • 品牌网站建设设计wordpress建电影网站
  • 建网站怎么挣钱手机要访问国外网站如何做
  • 门户网站ui设计定制礼品公司
  • 学校网站模版安徽省建设工程信息网网
  • 池州专业网站建设公司注册公司具体费用
  • 股票订阅网站开发wordpress付费破解版
  • 高清的宝安网站推广广告设计与制作专业认识
  • 辽宁省建设行业协会网站电商网站图片是谁做
  • 淘宝优惠券网站怎么做的低代码无代码平台
  • 天河区建设和水务局网站湛江市建网站
  • 网站设计大公司无线网站应建设在什么地方
  • 福建省港航建设发展有限公司网站win7 做服务器开网站
  • 关于百度网站的优缺点dw网站模板下载地址
  • 网站域名代理备案零食天堂专做零食推荐的网站
  • 忻州建设网站的公司宁波seo哪家最便宜
  • 企业网站报价关键词搜索引擎工具爱站
  • 高端网站开发网站建立需要多少钱
  • dw做的网站如何发布自建网站如何在百度上查到
  • 番禺市桥做网站公司大良网站建设公司
  • 徐州模板建站定制网站公司网站谁负责做
  • 做网站后端要学什么全国互联网备案信息查询系统
  • 域名网站排名做图软件ps下载网站有哪些
  • 地方性门户网站生鲜网站建设的总体目标
  • 苏州做网站多少钱东莞网站搭建哪家强
  • 书店网站建设设计方案北京网站建设公司排名
  • 西宁做网站君博优选网站建设对策
  • 沈阳建设企业网站浙江省住房和城乡建设厅网站 文件