typedef int SListDataType;
//链表中的一个节点
typedef struct Node{
SListDataType value; //值
struct Node *next; //下一个节点的地址
}Node;
//单链表
typedef struct SList{
Node *first;// *head 第一个节点的地址
} SList;
SList SListRemove(SList *slist, SListDataType v){
Node * c = slist->first;
//链表中一个节点都没有
if (c == NULL){
return;
}
//当v在第一个节点处
if (c->value == v){
Node * second = c->next;
free(c);
c = second;
}
else{
//当不是第一个节点时
while (c->next != NULL){
if (c->next->value == v){
Node * next = c->next->next;
free(c->next);
c->next = next;
return;
}
c = c->next;
}
}
}