#include <cstdio>
#include <stdlib.h>
typedef struct Node
{
int data;
struct Node * next;
} Node,* Linklist; //定义链表的结点,链表头
void Initlist (Linklist *CL) //初始化链表
{
*CL=(Linklist)malloc(sizeof(Node));
(*CL)->next=*CL; //初始化循环单链表的关键
}
void CreateFromTail(Linklist CL) //尾插发建表
{
Node *r,*s;
r=CL; //r总是指向链表的最后结点,s是新的结点
int flag=1; int num;
while(flag)
{
scanf("%d",&num);
if(num!= -1)
{
s=(Node *) malloc(sizeof(Node));
s->data=num;
r->next=s;
r=s;
}
else{
flag=0;
r->next=CL;
}
}
return ;
}
void Output(Linklist CL) //输出循环单链表
{
Node *temp;
temp=CL->next;
while(temp != CL)
{
printf("%d ",temp->data);
temp=temp->next;
}
printf("\n");
}
Linklist Unionlist(Linklist LA ,Linklist LB) //循环单链表的合并
{
Node *p,*q; //用指针结
数据结构 链表 循环单链表的建立 C语言版
最新推荐文章于 2025-11-08 22:09:50 发布

最低0.47元/天 解锁文章
369

被折叠的 条评论
为什么被折叠?



