{int data;
struct lnode *next;
lnode* head;
}LNode,*LinkList;//定义链表
static lnode* GetNode( int i ) // 新建并初始化节点
{
lnode *p;
p=(lnode*)malloc( sizeof( lnode));
if(!p)
{
printf("Error,the memory is not enough!\n");
exit(-1);
}
p->data=i;
p->next=NULL;
return p;
}
void creatlist(lnode *p,int n)//循环链表
{
int i;
p=GetNode(1);
p->head=p;
for(i=2;i<=n;i++)
{p->next->data=i;
p=p->next;}
p->next=p->head;}
struct lnode *next;
lnode* head;
}LNode,*LinkList;//定义链表
static lnode* GetNode( int i ) // 新建并初始化节点
{
lnode *p;
p=(lnode*)malloc( sizeof( lnode));
if(!p)
{
printf("Error,the memory is not enough!\n");
exit(-1);
}
p->data=i;
p->next=NULL;
return p;
}
void creatlist(lnode *p,int n)//循环链表
{
int i;
p=GetNode(1);
p->head=p;
for(i=2;i<=n;i++)
{p->next->data=i;
p=p->next;}
p->next=p->head;}