//循环单链表的初始化,建立,插入,查找,删除。//
//Author:Wang Yong
//
//Date: 2010.8.20
//
#include <stdio.h>
#include <stdlib.h>
typedef int ElemType;
///
//定义结点类型
typedef struct Node
{
ElemType data;
struct Node *next;
}Node,*LinkList;
//
//循环单链表的创建,采用尾插法建立单链表
LinkList LinkListCreatT()
{
LinkList L,r,p;
L = (Node *)malloc (sizeof(Node)); //初始化链表
L->next = L;
r = L;
//r始终指向最后一个结点
ElemType x;
while(scanf("%d",&x) != EOF)
{
p = (Node *)malloc(sizeof(Node));
p->data = x;
p->next = r->next;
r->next = p;
r = p;
}
r->next = L;
return L;
}
int main()
{
LinkList list,start;
list = LinkListCreatT();
for(start = list->next ;start != list;start = start->next)
printf("%d ",start->data);
printf("n");
return 0;
}
转载于:https://www.cnblogs.com/newwy/archive/2010/10/10/1847459.html
最后
以上就是醉熏黑裤最近收集整理的关于循环单链表的初始化,建立,插入,查找,删除。的全部内容,更多相关循环单链表内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复