这个程序有毛病吗?
Const p1 = 3
Const p2 = 7
Public Function zhigua(b() As Single, ByVal m As Integer) As String
Dim i As Integer, yaoshu As Integer
Dim biangua(1 To 6) As String
Dim sum As Single
yaoshu = 0: i = m
Do While yaoshu <= 5
If (b(i) < -p1) And (b(i) > -p2) Then
yaoshu = yaoshu + 1: i = i + 1
biangua(yaoshu) = "阴"
ElseIf (b(i) > p1) And (b(i) < p2) Then
yaoshu = yaoshu + 1: i = i + 1
biangua(yaoshu) = "阳"
ElseIf (b(i) < -p2) Then
yaoshu = yaoshu + 1: i = i + 1
biangua(yaoshu) = "阳"
ElseIf (b(i) > p2) Then
yaoshu = yaoshu + 1: i = i + 1
biangua(yaoshu) = "阴"
ElseIf b(i) < p1 And b(i) > -p1 Then
sum = 0
Do
sum = sum + b(i)
i = i + 1
Loop Until sum > p1 Or sum < -p1
Select Case CInt(sum)
Case Is < -p1
yaoshu = yaoshu + 1
biangua(yaoshu) = "阴"
Case Is < -p2
yaoshu = yaoshu + 1
biangua(yaoshu) = "阳"
Case Is > p1
yaoshu = yaoshu + 1
biangua(yaoshu) = "阳"
Case Is > p2
yaoshu = yaoshu + 1
biangua(yaoshu) = "阴"
End Select
End If
Loop
zhigua = biangua(1) + biangua(2) + biangua(3) + biangua(4) + biangua(5) + biangua(6)
End Function
上面的函数是把一个数组(数组的值的范围在(-10,10))的值分类计算,提取从m开始的n(n的值可由下面的dongyao函数计算)个数,按照不同的值用阴阳符号表示出来。
但使我疑问的是这个程序与我手工计算的结果经常不一样,不知什么原因,哪个高手能说说。
我用的是vb6.0。
Public Function dongyao(b() As Single, ByVal m As Integer) As Integer
Dim i As Integer, yaoshu As Integer, j!
Dim sum As Single
yaoshu = 0: i = m
Do While yaoshu <= 5
If Abs(b(i)) > 11 Then
dongyao = 20
Exit Function
ElseIf b(i) < -p1 Then
yaoshu = yaoshu + 1: i = i + 1
ElseIf b(i) > p1 Then
yaoshu = yaoshu + 1: i = i + 1
ElseIf b(i) < p1 And b(i) > -p1 Then
sum = 0
Do
sum = sum + b(i)
i = i + 1
Loop Until sum > p1 Or sum < -p1
yaoshu = yaoshu + 1
End If
Loop
dongyao = i - m
End Function
[解决办法]
可以直接修改帖子为 其他类,
管理菜单——〉移动
[解决办法]
我想删除这个帖子,但不知道怎么删除,大家不要回复了。谢谢。
[解决办法]
貌似发了就删不了
[解决办法]
友情Up...........