赞
踩
- int ListSortInsert (LinkList &L, ElemType e,int (*compare)(ElemType,ElemType))
- {
- /********** Begin **********/
- LNnode* s = (LNnode*)malloc(sizeof(LNnode)),*p,*q;
- if (s == NULL) return 0;
- s->data = e;
- s->next = NULL;
- p = L;
- q = L->next;
- if (q==NULL)
- {
- L->next = s;
- return 1;
- }
- while (q != NULL)
- {
- if (compare(e,q->data)!=-1)
- {
- p = q;
- q = q->next;
- }
- else
- {
- s->next = p->next;
- p->next = s;
- return 1;
- }
- }
- p->next = s;
- return 1;
- /********** End **********/
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。