Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #include "listas_libreria.txt"
- // apareo de listas
- bool es_menor (int a, int b)
- {
- if (a < b)
- return true;
- else
- return false;
- }
- void apareo_de_listas (lista& a, lista& b, lista& c)
- {
- node* p = a.root;
- node* q = b.root;
- while (p != 0 and q != 0)
- {
- if (p->entry == q->entry)
- {
- insertar_nodo_al_final (c, p->entry);
- p = p->next;
- q = q->next;
- }
- else if (es_menor(p->entry, q->entry))
- {
- insertar_nodo_al_final(c,p->entry);
- p = p->next;
- }
- else
- {
- insertar_nodo_al_final(c,q->entry);
- q = q->next;
- }
- }
- if (p == 0)
- while (q != 0)
- {
- insertar_nodo_al_final(c,q->entry);
- q = q->next;
- }
- else
- while (p != 0)
- {
- insertar_nodo_al_final(c,p->entry);
- p = p->next;
- }
- }
- int main()
- {
- // if (es_menor(2,2))
- // cout << "super" << endl;
- lista a;
- for (int i = 0; i<10; i++)
- insertar_nodo_al_final(a,i+12);
- mostrar_lista(a);
- lista b;
- for (int i = 0; i<10; i++)
- insertar_nodo_al_final(b,i);
- mostrar_lista(b);
- lista c;
- apareo_de_listas (a,b,c);
- cout << endl;
- mostrar_lista(c);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement