#include<stdio.h>
#include<stdlib.h>
typedef int ElemType;
typedef struct lnode
{
ElemType data;
struct lnode *next;
}LNode,*LinkList;
int CreateLinkList(LinkList &L,int num) //创建循环单链表
{
int i;
LinkList s,p;
p = L = (LNode *)malloc(sizeof(LNode));
L->next = L; //空的循环单链表
for(i = 1;i <= num;i++) //顺位序创建
{
s = (LinkList)malloc(sizeof(LNode));
s->data = i;
s->next = p;
p->next = s;
p = s;
}
return num;
}
void LinkListInsert(LinkList &L,ElemType e,int pos) //插入元素
{
LinkList p,s;
int j;
p = L;
j = 0;
while(p && j < pos -1)
{
p = p->next;
j++;
}
s = (LinkList)malloc(sizeof(LNode));
s->data = e;
s->next = p->next;
p->next = s;
}
void LinkListDelete(LinkList &L,ElemType &e,int pos) //删除
{
LinkList p,q;
int j = 0;
p = L;
while(p->next && j < pos - 1)
{
09-03
868
10-05
1万+
08-01
4075
02-04
1450
08-07
1692