[求助]拜请各位大虾有关下标越界的问题!!!感激涕零
<P>我在编一个求点集凸包的程序</P><P>采点集的程序部分已经搞定了但到了去极点部分就老提示下标越界</P>
<P>下面是我的程序:</P>
<P>Option Explicit<BR>Private Type pointinfo<BR>x As Single '点的x 坐标值<BR>y As Single '点的y 坐标值<BR>q As Single '与水平线的夹角<BR>End Type<BR>Dim p0 As pointinfo<BR>Dim p(1 To 200) As pointinfo '点集<BR>Dim ps(1 To 200) As pointinfo '排序后的点集<BR>Dim pi(1 To 200) As pointinfo '极点<BR>Dim n, m, d As Integer<BR>Dim x0, y0 As Single<BR>Dim l, e As Integer</P>
<P>Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)<BR>DrawWidth = 4<BR>If n = 0 Then<BR> p0.x = x<BR> p0.y = y<BR> Circle (x, y), 100, RGB(255, 0, 255)<BR>Else '输入点集<BR> p(n).x = x<BR> p(n).y = y<BR> Circle (x, y), 10, RGB(255, 255, 0)<BR>End If<BR>n = n + 1<BR>x0 = x<BR>y0 = y</P>
<P>End Sub</P>
<P><BR>Private Sub Command2_Click()<BR>Dim i As Integer<BR>Dim q As Single<BR>p(n).x = x0<BR>p(n).y = y0<BR>Const pi = 3.14<BR>For i = l To n<BR>If p(i).y - p0.y = 0 Then (总是在这句提示下标越界)<BR> If p(i).x - p0.x = 0 Then<BR> p(i).q = 90<BR> ElseIf p(i).x - p0.x > 0 Then<BR> p(i).q = 180 / pi * Atn((p(i).y - p0.y) / (p(i).x - p0.x))<BR> Else<BR> p(i).q = 180 / pi * Atn((p(i).y - p0.y) / (p(i).x - p0.x)) + 180<BR> End If<BR>ElseIf p(i).y - p0.y < 0 Then<BR> If p(i).x - p0.x = 0 Then<BR> p(i).q = 270<BR> ElseIf p(i).x - p0.x > 0 Then<BR> p(i).q = 360 + 180 / pi * Atn((p(i).y - p0.y) / (p(i).x - p0.x))<BR> Else<BR> p(i).q = 180 + 180 / pi * Atn((p(i).y - p0.y) / (p(i).x - p0.x))<BR> End If<BR>End If<BR> <BR>Next i</P>
<P>End Sub</P>
[原创]
<P>请各位高手帮忙啊</P><P>救命</P> 在Command2_Click中,n值是多少,在哪里确定? mccad发表于2006-5-13 5:55:00static/image/common/back.gif在Command2_Click中,n值是多少,在哪里确定?
<P>随机的</P>
<P>在点击之前点个点多少点n为多少</P>
<P>上限为200</P>
[求助]
mccad发表于2006-5-13 5:55:00static/image/common/back.gif在Command2_Click中,n值是多少,在哪里确定?<P><BR>这个问题已经解决了</P>
<P>还是要感谢你的热心帮忙</P>
页:
[1]