Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- nodo* C(nodo*& Q, int k)
- {
- if(!Q)
- return NULL;
- if(k==1)
- {
- nodo*a=Q;
- Q=Q->next;
- a->next=NULL;
- return a;
- }
- else
- {
- nodo*b=C(Q->next,k-1);
- nodo*a=Q;
- Q=Q->next;
- a->next=b;
- return a;
- }
- }
- nodo* G(nodo*Q1, nodo*Q2, int k)
- {
- if ((!Q1) && (!Q2)) return NULL;
- nodo *concat = C(Q1, k);
- nodo *temp = concat;
- while (temp->next != NULL) temp = temp->next;
- temp->next = C(Q2, k);
- while (temp->next != NULL) temp = temp->next;
- temp->next = G(Q1, Q2, k);
- return concat;
- }
Advertisement
Add Comment
Please, Sign In to add comment