bsirhell 发表于 2006-11-9 06:45:00

[求助]点组中具有同一X坐标的最大点和最小点

请教高手,
如何获得点组ptarr()中具有同一X坐标的最大点和最小点?

bsirhell 发表于 2006-11-9 12:27:00

Function getmaxy(ptarr(), y As Double) As Variant'获得具人相同Y坐标的最大点
If UBound(ptarr) = 0 Then max = ptarr(i)
For i = 0 To UBound(ptarr)
For j = 0 To UBound(ptarr)
   If ptarr(i)(1) = y And ptarr(j)(1) = y Then
   If ptarr(i)(0) > ptarr(j)(0) Then
   max = ptarr(i)
   End If
   End If
Next j
Next i
getmaxy = max
End Function
运行以后发现此函数有问题
而下面的没有
Function gomin(ptarr(), y As Double) As Variant
'获得具人桢同Y坐标的最小点
For i = 0 To UBound(ptarr)
   For j = 0 To UBound(ptarr)
   If ptarr(i)(1) = y And ptarr(j)(1) = y Then
   If ptarr(i)(0) > ptarr(j)(0) Then
   min = ptarr(j)
   End If
   End If
Next j
Next i
gomin = min
End Function
请问错在哪?
如果点组中有Y坐标的点只有一点,该强何处理?
页: [1]
查看完整版本: [求助]点组中具有同一X坐标的最大点和最小点