Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. struct node *od_x_do_y(struct node *head, int x, int y){
  2. if (head != NULL && head->next != NULL)
  3. {
  4. struct node *znajdzx = head;
  5. struct node *znajdzy = head;
  6. struct node *tail = head;
  7. struct node *p;
  8.  
  9. while (tail->next != NULL) tail = tail->next;
  10.  
  11. while (znajdzx != NULL){
  12. if (znajdzx->val == x){
  13. while (znajdzy != NULL){
  14. if (znajdzy->val == y){
  15. while (znajdzx->next != znajdzy){
  16. p = znajdzx->next;
  17. znajdzx->next = p->next;
  18. p->next = tail->next;
  19. tail->next = p;
  20. tail = p;
  21. }
  22. return;
  23. }
  24. else znajdzy = znajdzy->next;
  25. }
  26. }
  27. else znajdzx = znajdzx->next;
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement