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

建站还有前途么贵阳手机网站建设公司

建站还有前途么,贵阳手机网站建设公司,公司seo是指什么意思,网站建设怎么更换图片✅作者:简单^不简单 🔥系列专栏:C语言数据结构 💖如果文章有错误,时刻欢迎大家的指正。当然觉得博主的文章还不错的话,请点赞👍收藏⭐️留言📝 💬格言:希望我…

✅作者:简单^不简单
🔥系列专栏:C语言+数据结构
💖如果文章有错误,时刻欢迎大家的指正。当然觉得博主的文章还不错的话,请点赞👍+收藏⭐️+留言📝
💬格言:希望我们都能朝着光走‍‍‍🐱‍🏍

目录

相关知识点

        1.线性表

        2.顺序表

        3.链表

相关操作

1.定义数据结构

2.插入

2.1头插法

2.2尾插法

3.删除

完整代码


相关知识点

1.线性表

  • 定义:线性表 (linear list) 是 数据结构 的一种,一个线性表是n个具有相同特性的数据元素的有限序列。
  • 特点 

        1.有限的序列

        2.序列中的每一个元素都有唯一前驱和后继

2.顺序表

        分配一块连续的内存去存放这些元素,例如编程语言中的素组。

3.链表

        内存是不连续的,元素会各自被分配一块内存,内存和内存之间用指针进行相连。

 本文重点对单链表的相关操作进行讲解

相关操作

1.定义数据结构

typedef struct Node{int data;struct Node* next;
}Node;

2.插入

2.1头插法

                

        将头指针指向的节点赋值给新结点中next指向的节点,再将头结点的next从新指向node

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

2.2尾插法

          

        创建一个新结点,将值传入其中,再将新结点的next—>NULL,最后通过遍历找到以前的尾元素,将尾元素的next指向该元素。

//尾插法
void tailInsert(Node* list,int data){Node* head = list;Node* node = (Node*)malloc(sizeof(Node));node->data = data;node->next = NULL;list = list->next;while(list->next){list = list->next;}list->next = node;head->data++;
}

3.删除

                 

        删除指定节点时,要注意指针指向的节点是否为空,之后便是进行扫描与交换数据域,再之后就是进行断开释放空间等操作

void delete(Node* list,int data){Node* pre = list;Node* current = list->next;while(current){if(current->data==data){pre->next = current->next;free(current);break;}pre = current;current = current->next;}list->data--;
}

完整代码

#include<stdio.h>
#include<stdlib.h>//开辟空间的头文件//定义数据结构
typedef struct Node{int data;struct Node* next;
}Node;//初始化头节点
Node* initList(){Node* list =(Node*)malloc(sizeof(Node));list->data = 0;list->next = NULL;return list;}//头插法
void headInsert(Node* list,int data){Node* node =(Node*)malloc(sizeof(Node));node->data = data;node->next = list->next;list->next = node;list->data++;
}//尾插法
void tailInsert(Node* list,int data){Node* head = list;Node* node = (Node*)malloc(sizeof(Node));node->data = data;node->next = NULL;list = list->next;while(list->next){list = list->next;}list->next = node;head->data++;
}//删除操作
void delete(Node* list,int data){Node* pre = list;Node* current = list->next;while(current){if(current->data==data){pre->next = current->next;free(current);break;}pre = current;current = current->next;}list->data--;
}//遍历操作
void printList(Node* list){list = list->next;while(list){printf("%d",list->data);list = list->next;}printf("\n");
}int main(){Node* list = initList();headInsert(list,1);headInsert(list,2);headInsert(list,3);headInsert(list,4);headInsert(list,5);tailInsert(list,6);tailInsert(list,7);tailInsert(list,8);tailInsert(list,9);tailInsert(list,10);delete(list,5);delete(list,10);delete(list,3);printList(list);return 0;}

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

相关文章:

  • 做网站需要了解什么网站建站作业
  • 网站建设与规划实训总结自适应网站模板怎么做
  • 网站排版类型网站后台编辑
  • 做本地网站卖WordPress安装在Windows
  • 海南省住房与城乡建设部网站房产网站定制
  • 网站建设与管理专业课程网站开发 项目职责
  • 如何购买网站主机河北二级建造师考试最新消息
  • 唐山网站建设求职简历网站推广服务好公司排名
  • 网站海外推广外包微网站开发 课程标准
  • 贵阳搜索玩的网站上海网站开发一对一培训
  • 电子商务网站建设项目规划书注册开发公司
  • 将网站建设外包出去的好处企业如何在网站做认证
  • 做餐饮网站的目的与意义知名网站建设加盟合作
  • 怎么给网站做关键词排名纯静态企业网站模板免费下载
  • 想建一个网站免费网站注册com
  • 搜书网站 怎么做郑州网站建设十大公司
  • 厦门商务网站建设做餐饮酒店网站
  • 网站的文章参考文献怎么做物流网站功能
  • 南京网站设计公司有哪些公司电子商务网站建设模式
  • 苏州企业网站建设制作服务网站开发公司薪酬绩效
  • 贵州建设厅网站首页二级建造师成绩查询提供邯郸手机网站建设
  • 用vs做网站后台pc手机模板网站建设
  • 上海建设厅网站查询免费行情网站app页面
  • 深圳市手机网站建设报价wordpress+中国+论坛
  • 惠阳区建设局网站手机版刷赞网站建设
  • 微信网站开发之前要学会什么信誉好的昆明网站建设
  • 微信怎么做淘客网站微信开发者文档官网
  • 沈阳手机网站建设网站建设服务定制
  • 提供设计网站效果图沈阳关键词网站排名
  • 凡科建站做网站需要几天领诺科技网站建设