Advertisement
JosepRivaille

X22646: Trenat de cues

Jan 9th, 2016
891
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. void trenat(Cua &c)
  2. /* Pre: p.i. = C1, c = C2 */
  3. /* Post: el p.i. passa a ser el resultat de trenar C1 i C2; c passa a ser buida */
  4. {
  5.     node_cua *pi = this->primer_node;
  6.     node_cua *first_aux = this->primer_node;
  7.     node_cua *cn = c.primer_node;
  8.  
  9.     if (pi == NULL) this->primer_node = c.primer_node;
  10.     else {
  11.         while (pi != NULL && cn != NULL) {
  12.             node_cua *aux = pi->seguent;
  13.             pi->seguent = cn;
  14.             pi = aux;
  15.             aux = cn->seguent;
  16.             if (pi != NULL) cn->seguent = pi;
  17.             cn = aux;
  18.         }
  19.     }
  20.  
  21.     this->longitud += c.longitud;
  22.     c.longitud = 0;
  23.     pi = first_aux;
  24. }
  25.  
  26. //JosepRivaille
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement