typedef struct LNode {
int val;
LNode *nxt;
LNode(int _val, LNode *_l) : val(_val), nxt(_l) {}
} LNode;
LNode *Troot;
inline void out(LNode * root) {
cout << root -> val << ' ';
if (root -> nxt != NULL) out(root -> nxt);
}
inline void del(LNode * root, int x, LNode *pre) {
if (root -> val == x) {
LNode *p = root;
if (pre == NULL) {
root = Troot = root -> nxt;
} else {
pre -> nxt = root->nxt;
root = pre;
}
free(p);
}
if (root -> nxt != NULL) del(root -> nxt, x, root);
}