對著自己的資料型別做相應地修改:
void Delete(SeqList L, DataType x)
int i = 0, j;
for (j = 0; j < L->length; j ++)
if (L->data[j] != x)
{
if (i < j)
L->data[i] = L->data[j];
i ++;
}
L->length = i;
void Delete_List(LinkList head, DataType x)
Node *p, *q, *s;
p = head->next;
q = head;
while (p != NULL)
if (p->data != x)
q = p;
else
s = p;
q->next = s->next;
free(s);
p = q->next;
對著自己的資料型別做相應地修改:
void Delete(SeqList L, DataType x)
int i = 0, j;
for (j = 0; j < L->length; j ++)
if (L->data[j] != x)
{
if (i < j)
L->data[i] = L->data[j];
i ++;
}
L->length = i;
}
void Delete_List(LinkList head, DataType x)
Node *p, *q, *s;
p = head->next;
q = head;
while (p != NULL)
{
if (p->data != x)
q = p;
else
{
s = p;
q->next = s->next;
free(s);
}
p = q->next;
}
}