# 删除链表中等于给定值val的所有节点

（1）删除链表中等于给定值val的所有节点

（2）删除链表中重复的结点

（3）从尾到头打印链表

//笔试题：
/*

*/
struct Node{
int value;
Node* next;
};

Node* CreatNode(int value, Node* next = NULL){
Node* node = new Node;
node->value = value;
node->next = next;
return node;
}
}

while (cur != NULL){
if (x == cur->value){
prev->next = cur->next;
cur = cur->next;
}
else{
prev = cur;
cur = cur->next;
}
}

}
}

//打印链表
while (curr != NULL){
cout << curr->value << ends;
curr = curr->next;
}
cout << endl;
}

//面试题5：从尾到头打印链表
return;
}
else{
}
}

void test(){
Node* g = CreatNode(5);
Node* f = CreatNode(4,g);
Node* e = CreatNode(4,f);
Node* d = CreatNode(3,e);
Node* c = CreatNode(3,d);
Node* b = CreatNode(2,c);
Node* a = CreatNode(1,b);

PrintList(a);

cout << endl;

}
//删除已排序链表中重复的结点，重复节点不保留。
}

Node* first = new Node;  //新建一个头结点就简单很多了

Node* last = first;
while (curr != NULL & curr->next != NULL){
if (curr->value == curr->next->value){
int v = curr->value;
while (v == curr->value){
curr = curr->next;
}
last->next = curr;
}
else{
last = curr;
curr = curr->next;
}
}
return first->next;
}