나는 (ADT) 바이너리 쉐어 트리의 구현을 수행했는데, 나는 아들이 가진 부모의 수를 세는 기능을 수행해야했습니다. 차이는 5보다 적습니다. 프로그램이 작동하지만이 펑션 만 실패합니다.HW3.exe의 0xCF에서 처리되지 않은 예외 : 0xC0000005 : 0x00000004 액세스 위치 읽기 0x00000004
'return'(재귀 적)에서 중단 점을 얻었습니다. 사용자가 입력하는 경우 return
문에서
int difference(BSTNode *root, comperFunc cmpFn, comperFunc lesserThenFive)
{
int count = 0;
if (root)
{
count = 0;
if (root->Left && root->Right)
{
//if root->Right > root->Left
if (cmpFn(root->Right->key, root->Left->key) == 1)
{
if (lesserThenFive(root->Right->key, root->Left->key))
count = 1;
}
//if root->Right < root->Left
if (cmpFn(root->Right->key, root->Left->key) == -1)
{
if (lesserThenFive(root->Left->key, root->Right->key))
count = 1;
}
}
}
return difference(root->Left, cmpFn, lesserThenFive) + difference(root- >Right, cmpFn, lesserThenFive) + count;//here is the break point
}
[mcve]를 제공해주십시오. –
'return difference (root-> Left, ...':'루트'가'NULL'이면'NULL' 디어 레퍼런스가 발생합니다. – BLUEPIXY
@Lundin 말하기가 불가능하다는 것을 알게되었습니다 :-) – JeremyP