Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.16 KB | None | 0 0
  1. void solve(struct SLLNode **first, int x)
  2. {
  3.     struct SLLNode *nodeX = NULL;
  4.     struct SLLNode *pomaliX = NULL;
  5.     struct SLLNode *pogolemiPredX = NULL;
  6.     struct SLLNode *pogolemiPosleX = NULL;
  7.     struct SLLNode *curr = (*first);
  8.     while (curr != NULL)
  9.     {
  10.         if (nodeX == NULL && curr->Value == x)
  11.         {
  12.             nodeX = curr;
  13.             continue;
  14.         }
  15.  
  16.         if (curr->Value < x)
  17.         {
  18.             pomaliX = sll_insertLast(pomaliX, curr->Value);
  19.         }
  20.         else
  21.         {
  22.             if (nodeX == NULL)
  23.             {
  24.                 pogolemiPredX = sll_insertLast(pogolemiPredX, curr->Value);
  25.             }
  26.             else
  27.             {
  28.                 pogolemiPosleX = sll_insertLast(pogolemiPosleX, curr->Value);
  29.             }
  30.         }
  31.  
  32.         curr = curr->Next;
  33.     }
  34.  
  35.     curr = pogolemiPredX;
  36.     while (curr != NULL)
  37.     {
  38.         pomaliX = sll_insertLast(pomaliX, curr->Value);
  39.         curr = curr->Next;
  40.     }
  41.     curr = pogolemiPosleX;
  42.     while (curr != NULL)
  43.     {
  44.         pomaliX = sll_insertLast(pomaliX, curr->Value);
  45.         curr = curr->Next;
  46.     }
  47.  
  48.     (*first) = pomaliX;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement