SHARE
TWEET

linkedlistremoveelement

a guest Apr 22nd, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Node* deleteValues(Node* head, int value)
  2. {
  3.     Node* current = head;
  4.     while ((*current).value == value && current != NULL)
  5.     {
  6.         head = (*current).next;
  7.         current = (*current).next;
  8.     }
  9.     if (current == NULL)
  10.     {
  11.         return head;
  12.     }
  13.     while ((*current).next != NULL)
  14.     {
  15.         if ((*(*current).next).value == value)
  16.         {
  17.             (*current).next = (*(*current).next).next;
  18.         }
  19.         else
  20.         {
  21.             current = (*current).next;
  22.         }
  23.     }
  24.     return head;
  25. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top