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

刚刚发生在昆明的大事无锡seo

刚刚发生在昆明的大事,无锡seo,企业门户网站建设 北京,济南网站建设公司哪个好点呢2.单循环链表 data|next——>data|next——>data|next——>头节点 1.初始化链表 2.增加节点(头插法、尾插法) 3.删除节点 4.遍历链表 定义一个结构体,存放data域和指针域: typedef struct Node {//定义一个结构体&…

2.单循环链表
data|next——>data|next——>data|next——>头节点
1.初始化链表
2.增加节点(头插法、尾插法)
3.删除节点
4.遍历链表

定义一个结构体,存放data域和指针域:

typedef struct Node {//定义一个结构体,存放data域和指针域int data;//数据域类型struct Node* next;
}Node;

初始化链表:

Node* initList() {//初始化链表Node* L = (Node*)malloc(sizeof(Node));L->data = 0;L->next = L;return L;
}

头插法:

void headInsert(Node* L, int data) {//头插法Node* node = (Node*)malloc(sizeof(Node));node->data = data;node->next = L->next;L->next = node;
}

尾插法 :

void tailInsert(Node* L, int data) {//尾插法Node* n = L;Node* node = (Node*)malloc(sizeof(Node));node->data = data;while (n->next != L) {n = n->next;}node->next = L;n->next = node;
}

删除:

int Delete(Node* L, int data)//删除
{Node* preNode = L;Node* node = L->next;while (node != L){if (node->data == data) {//deletepreNode->next = node->next;free(node);return true;}preNode = node;node = node->next;}return false;
}

遍历链表:

void printList(Node* L) {//遍历链表Node* node = L->next;while (node != L) {printf("%d->", node->data);node = node->next;}printf("NULL\n");
}

main函数:

int main()
{Node* L = initList();headInsert(L, 1);headInsert(L, 2);headInsert(L, 3);headInsert(L, 4);headInsert(L, 5);tailInsert(L, 6);tailInsert(L, 7);tailInsert(L, 8);tailInsert(L, 9);tailInsert(L, 10);printList(L);Delete(L, 4);Delete(L, 5);printList(L);return 0;
}

单循环链表函数

typedef struct Node {//定义一个结构体,存放data域和指针域int data;//数据域类型struct Node* next;
}Node;Node* initList() {//初始化链表Node* L = (Node*)malloc(sizeof(Node));L->data = 0;L->next = L;return L;
}void headInsert(Node* L, int data) {//头插法Node* node = (Node*)malloc(sizeof(Node));node->data = data;node->next = L->next;L->next = node;
}void tailInsert(Node* L, int data) {//尾插法Node* n = L;Node* node = (Node*)malloc(sizeof(Node));node->data = data;while (n->next != L) {n = n->next;}node->next = L;n->next = node;
}int Delete(Node* L, int data)//删除
{Node* preNode = L;Node* node = L->next;while (node != L){if (node->data == data) {//deletepreNode->next = node->next;free(node);return true;}preNode = node;node = node->next;}return false;
}void printList(Node* L) {//遍历链表Node* node = L->next;while (node != L) {printf("%d->", node->data);node = node->next;}printf("NULL\n");
}int main()
{Node* L = initList();headInsert(L, 1);headInsert(L, 2);headInsert(L, 3);headInsert(L, 4);headInsert(L, 5);tailInsert(L, 6);tailInsert(L, 7);tailInsert(L, 8);tailInsert(L, 9);tailInsert(L, 10);printList(L);Delete(L, 4);Delete(L, 5);printList(L);return 0;
}

http://www.yidumall.com/news/98988.html

相关文章:

  • 个人主页设计模板优化网站的方法有哪些
  • 网站买空间广告投放方式
  • 顺德网站建设价格创建网站的基本流程
  • 国外服务器 网站进行经营性活动seo是什么工作
  • 河北网站建设价格低品牌战略
  • 全国网站制作公司郑州seo
  • wordpress前台构架图seo网站平台
  • 怎么查看域名网站的容量到期优化网站关键词优化
  • 做品牌推广用什么网站灰色词首页排名接单
  • 手机可以做3d动漫视频网站有哪些电工培训
  • 长沙公众号开发杭州seo推广优化公司
  • 南宁正规公众号网站建设推广线下推广的渠道和方法
  • wordpress 门户网站源码百度高级搜索技巧
  • 电子商务网站建设与管理实验人民日报最新消息
  • 网页版传奇链接微信seo是什么意思
  • 织梦做的网站网速打开慢是怎么回事唯尚广告联盟平台
  • 淘宝客是如何做网站与淘宝对接的搜索引擎营销简称seo
  • 网站申请微信支付网络营销的主要方式
  • 内部券网站怎么做做排名优化
  • 小红书推广策略百度关键词优化平台
  • 网站建设开放的端口网站建设方案及报价
  • 推广网站怎么建网络营销管理名词解释
  • 婚庆行业网站建设sem电子扫描显微镜
  • 网站地图 百度域名注册流程和费用
  • 移动互联网开发的学习心得百度搜索排名优化
  • 沈阳化工大学建设工程全专业优化公司
  • 网站 目标seo怎么做教程
  • 吉安做网站优化珠海seo排名收费
  • 秦皇岛市建设路小学网站站长之家素材网
  • ps设计网站百度指数查询入口