Yoli16 de Junio del 2003
PreguntaLlevo unos dias dandole vueltas a esta función q me falla y no sé donde!!, el código me compila bien, pero cd hago la prueba me sale la lista vacía!!, me gustaría q alguien la mirarse y encontrarse el error!!
La función d Intercción d dos listas:
TIPO_LISTA Interseccion (TIPO_LISTA l, TIPO_LISTA m)
{
TIPO_LISTA n;
POSICION p,q;
if(NumElementos(l)==0 || NumElementos(m)==0)
return NULL;
n=Crear();
p=Primero(l);
q=Primero(m);
while (p!=NULL)
{
while (q!=NULL)
{
if (Elemento(p).dato==Elemento(q).dato)
Insertar(n,Primero(n),Elemento(p));
q=Siguiente(q);
}
p=Siguiente(p);
}
return n;
}
La función d Intercción d dos listas:
TIPO_LISTA Interseccion (TIPO_LISTA l, TIPO_LISTA m)
{
TIPO_LISTA n;
POSICION p,q;
if(NumElementos(l)==0 || NumElementos(m)==0)
return NULL;
n=Crear();
p=Primero(l);
q=Primero(m);
while (p!=NULL)
{
while (q!=NULL)
{
if (Elemento(p).dato==Elemento(q).dato)
Insertar(n,Primero(n),Elemento(p));
q=Siguiente(q);
}
p=Siguiente(p);
}
return n;
}
