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

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

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

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

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