Advertisement
adwas33

Untitled

Nov 30th, 2021
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. void split(Node *&h,Node *& first,Node *&second)
  2. {
  3. Node * p=h;
  4. Node * iterator=h;
  5. first= nullptr;
  6. second = nullptr;
  7. int i=0;
  8. while(p!= nullptr) // policz liczbę elementów
  9. {
  10. p=p->next;
  11. i++;
  12. }
  13. i/=2;
  14. while(i!=0)
  15. {
  16. i--;
  17. add(first,iterator->val);
  18. iterator=iterator->next;
  19. }
  20. while(iterator!= nullptr)
  21. {
  22. add(second,iterator->val);
  23. iterator=iterator->next;
  24. }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement