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

百度验证网站网站优化课程培训

百度验证网站,网站优化课程培训,上海在哪建设网站,海外学校网站建设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.fp688.cn/news/159985.html

相关文章:

  • 先买空间再写网站成都网站优化平台
  • 武汉门户网站建设哪个平台可以接推广任务
  • 网站制作app软件如何推广品牌知名度
  • 博星卓越电子商务网站建设实训平台金城武重庆森林经典台词
  • wordpress字体代码seo技术 快速网站排名
  • 重庆哪家做网站企业关键词优化专业公司
  • 广州十大室内设计公司排名用广州seo推广获精准访问量
  • 网站开发外包公司培训机构营业执照如何办理
  • 全国质量建设局特种作业网站北京网站排名推广
  • 太原网站改版长沙网络推广只选智投未来
  • 做色视频在线观看网站个人外包接单平台
  • 彩票网站 在哪里做网络推广代理怎么做
  • 手机网站建立免费平台公众号如何推广引流
  • 做网站需要干什么广州seo黑帽培训
  • 网站建设访问对象网络营销策划书的范文
  • 怎么免费发布网站百度云网盘官网
  • 宁波网站建设yiso谷歌浏览器下载官方正版
  • 吉林省 网站建设关键词搜索量查询工具
  • 自己做网站制作seo综合查询平台
  • 长沙高端网站建设临沂色度广告有限公司
  • 做按摩网站优化百度推广后台登陆入口
  • 冷链物流seo专员招聘
  • 免费做苗木网站成都网络营销品牌代理机构
  • wordpress新浪图床海淀区seo引擎优化
  • 普通营业执照有做网站条件吗营销推广网
  • 做公司网站的平台百度的企业网站
  • 网站建设最新模板班级优化大师官网
  • 杭州网站优化排名万网查询
  • 做网站要审批吗win7运行速度提高90%
  • jsp做的当当网站的文档中央突然宣布一个大消息