参考:http://www.cnblogs.com/newwy/archive/2010/10/10/1847459.html
//循环单链表的初始化,建立,插入,查找,删除。//
//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;
}