# 链表

#include <stdio.h>
#include <stdlib.h>

#define  OK  1
#define  ERROR  0

typedef int ElemType, Status;

typedef struct LNode
{
ElemType  data;  // 数据域
struct LNode *next; // 指针域

{
//将元素e插入到有序的链表L中，使其仍有序

pOne->data = e;
pOne->next = NULL;

if( L->next == NULL)
{
L->next = pOne;
return 1;
}
do
{
if (e < L->next->data)
{
pOne->next = L->next;
L->next    = pOne;
return 1;
}
L = L->next;
}while(L->next != NULL);
L->next = pOne;
return 0;
}

{
//新建链表，包括建立头结点，输入值和对ListInsert_L 函数的调用。
L->next = NULL;
ElemType e;

while (1)
{
scanf("%d", &e);
if (e < 0)
break;
else
ListInsert_L(L, e);
}

}

void Delete_Between(LinkList L, int mink, int maxk)
{
//删去链表中值介于mink,maxk的结点
if(L != NULL)
{
pTwo    = NULL,
pClient1= NULL,
pClient2= NULL;

while (L != NULL)
{
if (L->next->data > mink)
{
pOne = L;
break;
}
L = L->next;
}
while (L != NULL)
{
if (L->next->data > maxk)
{
pTwo = L->next;
break;
}
L = L->next;
}

if ((pOne->data - pTwo->data) >= 0)
{
printf("/n没有被删的结点,请注意两个数的循序和大小!/n");
return;
}
pClient1 = pOne->next;
pClient2 = pClient1->next;
pOne->next = pTwo;
while(pClient2 != pTwo)
{
free(pClient1);
pClient1 = pClient2;
pClient2 = pClient2->next;
}
free(pClient1);
}
else
{
printf("The list is empty!");
return;
}
}

{
//对链表中每一个结点均访问一次――显示结点的Data域的值
if( (L = L->next) != NULL)
while (L != NULL)
{
printf("%d/n", L->data);
L = L->next;
}
else
{
printf("The list is empty!");
return;
}
}

void main( void )
{
ElemType mink, maxk;

printf("请输入几个正整数，以负数结尾:");
CreateList_L(L);

DispList_L(L);

client = L;
while(client != NULL)
{
printf("%d/n", client);
client = client->next;
}