Galera estou com problema nessa questão:
-Tenho que comparar duas listas encadeadas e retornar 1 se forem iguais ou 0 se não forem.
A função está assim e não consigo progredir:
struct Node
{
int data;
struct Node *next;
}
int CompareLists(Node *headA, Node* headB)
{
/*se as duas forem vazias*/
if(headA->next==NULL && headB->next==NULL)
{
return 1;
}
if(headA->next==NULL || headB->next==NULL)
{
return 0;
}
while(headA->next!=NULL && headB->next!=NULL)
{
if(headA->data=!headB->data)
{
return 0;
}else{
return 1;
}
headA=headA->next;
headB=headB->next;
}
}
Acho que o problema está em percorrer a lista (headA=headA->next), mas não sei como fazer. Alguém pode me ajudar?