#2
azzbcc2015-10-23 10:47
|
程序代码:
typedef struct node
{
int data;
struct node *next;
}Linknode,*Link;
void Insertsort(Link L)
{
Link p,q,r,u;
p=L->next;L->next=NULL;//置空表
while(p!=NULL)
{
r=L;
q=L->next;
while(q!=p&&q->data<=p->data)
{
r=q;q=q->next;//q=L,而L已经被置空表了,上面说L->next=NULL;q->next不是为空了吗??
}
u=p->next;p->next=r->next;r->next=p;p=u;
}
}
{
int data;
struct node *next;
}Linknode,*Link;
void Insertsort(Link L)
{
Link p,q,r,u;
p=L->next;L->next=NULL;//置空表
while(p!=NULL)
{
r=L;
q=L->next;
while(q!=p&&q->data<=p->data)
{
r=q;q=q->next;//q=L,而L已经被置空表了,上面说L->next=NULL;q->next不是为空了吗??
}
u=p->next;p->next=r->next;r->next=p;p=u;
}
}