2.3链表 访问单个节点的删除
1 /* 2 struct ListNode { 3 int val; 4 struct ListNode *next; 5 ListNode(int x) : val(x), next(NULL) {} 6 };*/ 7 //将当前节点的后继节点的数据复制到当前节点,删除后继节点 8 class Remove { 9 public: 10 bool removeNode(ListNode* pNode) { 11 // write code here 12 if (pNode == NULL || pNode->next ==NULL) 13 return false; 14 ListNode* next = pNode->next; 15 pNode->val = next->val; 16 pNode->next = next->next; 17 delete next; 18 return true; 19 } 20 };
-------------------------------------------------
原创博客 转载请注明出处http://www.cnblogs.com/hslzju
-------------------------------------------------