#include <iostream>
using namespace std;
struct DNode{
int data;
DNode* pPrev, *pNext;
};
void delete1K(DNode* &pHead, int k);
void deleteAllKs(DNode* &pHead, int k);
//-----------------------------------------------------//
void delete1K(DNode* &pHead, int k) {
for(DNode *cur = pHead; cur; cur = cur->pNext) {
if(cur->data == k) {
if(cur->pNext)
cur->pNext->pPrev = cur->pPrev;
if(cur->pPrev)
cur->pPrev->pNext = cur->pNext;
else
pHead = cur->pNext;
delete cur;
break;
}
}
}
//-----------------------------------------------------//
void deleteAllKs(DNode* &pHead, int k) {
for(DNode* cur = pHead; cur;)
if(cur->data == k) {
if(cur->pNext)
cur->pNext->pPrev = cur->pPrev;
if(cur->pPrev)
cur->pPrev->pNext = cur->pNext;
else pHead = pHead->pNext;
DNode* tmp = cur;
cur = cur->pNext;
delete tmp;
}
else cur = cur->pNext;
}
//-----------------------------------------------------//
int main() {}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKc3RydWN0IEROb2RlewogICAgaW50IGRhdGE7CiAgICBETm9kZSogcFByZXYsICpwTmV4dDsKfTsKCnZvaWQgZGVsZXRlMUsoRE5vZGUqICZwSGVhZCwgaW50IGspOwp2b2lkIGRlbGV0ZUFsbEtzKEROb2RlKiAmcEhlYWQsIGludCBrKTsKCi8vLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0vLwoKdm9pZCBkZWxldGUxSyhETm9kZSogJnBIZWFkLCBpbnQgaykgewogICAgZm9yKEROb2RlICpjdXIgPSBwSGVhZDsgY3VyOyBjdXIgPSBjdXItPnBOZXh0KSB7CiAgICAgICAgaWYoY3VyLT5kYXRhID09IGspIHsKICAgICAgICAgICAgaWYoY3VyLT5wTmV4dCkKICAgICAgICAgICAgICAgIGN1ci0+cE5leHQtPnBQcmV2ID0gY3VyLT5wUHJldjsKICAgICAgICAgICAgaWYoY3VyLT5wUHJldikgCiAgICAg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