为了准备笔试面试,重新复习了单链表系列的数据结构
下面分别写的是带头结点和不带头结点的尾插法单链表的创建以及他们的遍历!
看注释应该都可以理解了。
/*********************************************************************************
* Copyright: (C) 2021 li liangshi<1007146932@qq.com>
* All rights reserved.
*
* Filename: have_head.c
* Description: This file is 带头结点的尾插法单链表
*
* Version: 1.0.0(2021年09月07日)
* Author: li liangshi <1007146932@qq.com>
* ChangeLog: 1, Release initial version on "2021年09月07日 09时13分15秒"
*
********************************************************************************/
#include <stdlib.h>
#include <stdio.h>
/* 结点定义 */
typedef struct node_s
{
int value;
struct node_s *next;
}Node;
/* 声明头结点 */
Node *head;
/* 初始化头结点 */
void Init_head(Node **head)
{
*head =(Node *)malloc(sizeof(Node));
(*head)->next = NULL;
}
/* 尾插法插入结点 */
void Inser_list(Node **head)
{
int num;
int i;
int data;
Node *node,