面试题见剑指offer:
struct ListNode { int value; ListNode *next; }; void DeleteNode(ListNode **pListHead,ListNode * pToBeDeleted) { if(!pListHead||!pToBeDeleted) return; if(pToBeDeleted->next) { ListNode *pNext=pToBeDeleted->next; pToBeDeleted->value=pNext->value; pToBeDeleted->next=pNext->next; delete pNext; pNext=NULL; } else if(*pListHead==pToBeDeleted) { delete pToBeDeleted; pToBeDeleted=NULL; *pListHead=NULL; } else { ListNode *pNode=*pListHead; while(pNode->next!=pToBeDeleted) pNode=pNode->next; pNode->next=NULL; delete pToBeDeleted; pToBeDeleted=NULL; } }