typedef struct _LNode
{
int data;
struct _LNode *next;
}LNode, *LinkList;
void DelNodes(LinkList head, int i, int k)
if(i>0 && k>0)
LNode *pre = head, *start = head->next, *last;
while((NULL != start) && (--i > 0))
pre = start;
start = start->next;
}
if(NULL == start)//個數小於i
return;
last = start;
while((NULL != last) && (--k > 0))
last = last->next;
if(NULL == last)//不足k個
pre->next = last;
while(start != last)
LNode *del = start;
free(del);
typedef struct _LNode
{
int data;
struct _LNode *next;
}LNode, *LinkList;
void DelNodes(LinkList head, int i, int k)
{
if(i>0 && k>0)
{
LNode *pre = head, *start = head->next, *last;
while((NULL != start) && (--i > 0))
{
pre = start;
start = start->next;
}
if(NULL == start)//個數小於i
return;
last = start;
while((NULL != last) && (--k > 0))
last = last->next;
if(NULL == last)//不足k個
return;
last = last->next;
pre->next = last;
while(start != last)
{
LNode *del = start;
start = start->next;
free(del);
}
}
}