#include <stdio.h>
#include <stdlib.h>
typedef struct llist{
int data;
struct llist *next;
}node,*link;
//输出链表
void printlist(link head)
{
link ptr;
ptr=head->next;
while(ptr!=NULL)
{
printf("%d ",ptr->data);
ptr=ptr->next;
}
printf("\n");
}
//创建链表
link createlist(int *array,int n)
{
link head;
link ptr,ptr1;
int i;
head=(link)malloc(sizeof(node));
if(!head)
{
printf("out of memory\n");
exit(1);
}
ptr=head;
printf("请输入你想输出的链表!\n");
for(i=0;i<n;i++)
{
scanf("%d",&array[i]);
ptr1=(link)malloc(sizeof(node));
if(!ptr1)
基本链表的创建,结点插入、删除
最新推荐文章于 2022-08-22 10:11:09 发布