int InsertListInOrder(LinkList L, ElemType x)
{ Node *s;
s=(Node *)malloc(sizeof(Node));
if (s==NULL) return ERROR;
s->data=x;
L=L->next;
while ( L!=NULL )
if ( x>L->data )
L=L->next;
else
{ s->next=L->next;
L->next=s;
}
return OK;
}
试试这个
int InsertListInOrder(LinkList L, ElemType x)
{
Node *s;
s=(Node *)malloc(sizeof(Node));
if (s==NULL) return ERROR;
s->data=x;
LinkList p=L;
L=L->next;
while ( L!=NULL )
{
if ( x>L->data )
{
p=L;
L=L->next;
}
else
{
s->next=p->next;
p->next=s;
break;
}
}
return OK;
}