#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
#include<conio.h>
#define ElemType int
struct LNode{ //定义单链表结点类型
int data; //数据域
struct LNode *next; //指针域
}; //LinkList相当于LNode*,即:struct LNode*
void creat(struct LNode*head,int size) {
struct LNode*p,*new_node;
int i,n;
p=head;//依次读入节点数据
for(i=1;i<=size;i++) {
scanf("%d",&n);
new_node=(struct LNode*)malloc(sizeof(struct LNode));
new_node->data=n;
new_node->next=NULL;
p->next=new_node;//新节点接入到链表尾
p=p->next;//p指针向后移
}
}
void print(struct LNode*head) {
struct LNode*p;
p=head->next;
while(p!=NULL){
printf("%d ",p->data);
p=p->next;
}
}
void ListInsert(struct LNode*head,int i,int e) {
struct LNode*p,*new_node;
int k;
new_node=(struct LNode*)malloc(sizeof(struct LNode));//生成新结点
new_node->data=e;
new_node->next=NULL;
p&#
c语言 链表存储实现
最新推荐文章于 2024-06-02 16:35:22 发布
![](https://img-home.csdnimg.cn/images/20240709112858.png)