链表
什么是链表?
链表是一种数据结构,利用结构体变量实现,链表包含数据域和指针域。
因为创建链表需要动态内存分配,但是分配的内存在内存中是不连续的,需要指针域将它们连起来,就像一条链子一样,所以叫链表。
创建
#include<stdio.h>
#include<stdlib.h>
typedef struct Node
{
int data;
Node* next;
}List;
List* Listcreat(int n)//创建链表
{
List* head, * node, * end;
head = (List*)malloc(sizeof(List));
end = head;
printf("请输入%d个数字\n", n);
for (int i