我对解决方案的尝试,我知道这是不对的,因为程序的输出不正确。我究竟做错了什么?
我有一个内部节点类,每个都有值字段。此方法应返回具有 ints min 和 max 之间的值字段的节点数。
//---------------- countInRange( Node, int, int ) ------------------
private int countInRange( Node cur, int min, int max )
{
if(cur == null)
return 0;
else {
if(cur.value >= min && cur.value <= max)
return (1+ countInRange(cur.next, min, max));
}
return 1;
}