Advertisement
pichumy

Untitled

Feb 2nd, 2014
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. bool LinkedList::deleteFourth()
  2. {
  3. int count = 1;
  4. if(this->length() < 4) return false;
  5. for(Node *temp=head; temp!=NULL; temp=temp->getNext())
  6. {
  7. if(count == 3)
  8. {
  9. if((temp->getNext()->getNext()) == NULL)
  10. {
  11. temp->setNext(NULL);
  12. return true;
  13. }
  14. else
  15. {
  16. temp->setNext(temp->getNext()->getNext());
  17. return true;
  18. }
  19. }
  20. count++;
  21. }
  22. return false;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement