我做的Hackerrank一个问题的最终到达,但每当我编译我的代码,它显示了控制到达非void函数结束。这里是我的源代码:控制在非void函数
/*
Compare two linked lists A and B
Return 1 if they are identical and 0 if they are not.
Node is defined as
struct Node
{
int data;
struct Node *next;
}
*/
int CompareLists(Node *headA, Node* headB)
{
if(headA==NULL&&headB==NULL)
{
return 1;
}
else if(headA!=NULL&&headB!=NULL)
{
while(headA!=NULL&&headB!=NULL)
{
if(headA->data==headB->data)
{
headA=headA->next;
headB=headB->next;
}
else
{
return 0;
exit (0);
}
return 1;
}
}
else
{
return 0;
}
}
请告诉如何纠正这一点,并提前致谢。
如果您修复缩进,它可能会帮助您查看发生了什么问题。 – Galik