ret_0

bad num 9 - lists

May 18th, 2018
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. void split(node* t, node* &p, int n)
  2. {
  3.     n--;
  4.     while(t && n)
  5.         t = t->next;
  6.     p = t->next;
  7.     t->next = 0;
  8. }
  9.  
  10. void copyl(node* t, node* &p)
  11. {
  12.     p = t;
  13.     node* q = p;
  14.     while(t)
  15.     {
  16.         q = t;
  17.         t = t->next;
  18.         q = q->next;
  19.     }
  20. }
  21.  
  22. void del_even(node* &t)
  23. {
  24.     node* p = t;
  25.     while(p)
  26.     {
  27.         if(!(p->data % 2))
  28.             delete_info(p, p->data);
  29.         p = p->next;
  30.     }
  31. }
  32.  
  33. void del_odd(node* &t)
  34. {
  35.     node* p = t;
  36.     while(p)
  37.     {
  38.         if(p->data % 2)
  39.             delete_info(p, p->data);
  40.         p = p->next;
  41.     }
  42. }
  43.  
  44. void split_evod(node* &t, node* &p)
  45. {
  46.     copyl(t, p);
  47.     del_even(t);
  48.     del_odd(p);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment