Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void solve(struct SLLNode **first, int x)
- {
- struct SLLNode *nodeX = NULL;
- struct SLLNode *pomaliX = NULL;
- struct SLLNode *pogolemiPredX = NULL;
- struct SLLNode *pogolemiPosleX = NULL;
- struct SLLNode *curr = (*first);
- while (curr != NULL)
- {
- if (nodeX == NULL && curr->Value == x)
- {
- nodeX = curr;
- continue;
- }
- if (curr->Value < x)
- {
- pomaliX = sll_insertLast(pomaliX, curr->Value);
- }
- else
- {
- if (nodeX == NULL)
- {
- pogolemiPredX = sll_insertLast(pogolemiPredX, curr->Value);
- }
- else
- {
- pogolemiPosleX = sll_insertLast(pogolemiPosleX, curr->Value);
- }
- }
- curr = curr->Next;
- }
- curr = pogolemiPredX;
- while (curr != NULL)
- {
- pomaliX = sll_insertLast(pomaliX, curr->Value);
- curr = curr->Next;
- }
- curr = pogolemiPosleX;
- while (curr != NULL)
- {
- pomaliX = sll_insertLast(pomaliX, curr->Value);
- curr = curr->Next;
- }
- (*first) = pomaliX;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement