展开全部
都是VB6.0上测试通过没有问题的程序。
1,逆序数计算
Private Function ReversOrder(ByVal InStr As String) As Long
Dim i As Integer, j As Integer, c As Long
Dim n() As Integer
ReDim n(Len(InStr))
For i = 1 To Len(InStr)
n(i) = Val(Mid(lnStr, i, 1))
For j = 1 To i - 1
If n(i) < n(j) Then
c = c + 1
End If
Next j
Next i
ReversOrder = c
End Function
2. 级数有限项求和
Private Sub Command1_click()
n = 0
For i = 1 To 100 '1 到100 项,你可改为你的项数
n = n + 1 / i '对级数的前100项求和:1/1+1/2+1/3+1/4...+1/100,你可改成你的级数
Next i
Text1.Text = Str(n) '在textbox里显示结果
End Sub
1,逆序数计算
Private Function ReversOrder(ByVal InStr As String) As Long
Dim i As Integer, j As Integer, c As Long
Dim n() As Integer
ReDim n(Len(InStr))
For i = 1 To Len(InStr)
n(i) = Val(Mid(lnStr, i, 1))
For j = 1 To i - 1
If n(i) < n(j) Then
c = c + 1
End If
Next j
Next i
ReversOrder = c
End Function
2. 级数有限项求和
Private Sub Command1_click()
n = 0
For i = 1 To 100 '1 到100 项,你可改为你的项数
n = n + 1 / i '对级数的前100项求和:1/1+1/2+1/3+1/4...+1/100,你可改成你的级数
Next i
Text1.Text = Str(n) '在textbox里显示结果
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询