求学霸给出用VB6.0做456这三道题目的答案。
展开全部
先来个第一题吧,不知道正不正确,参考一下
Private Sub Command1_Click()
Dim x As Integer, n As Integer, s As Double, s1 As Double, t As Double
Dim i As Integer, j As Integer
x = Val(InputBox("enter data x:"))
n = Val(InputBox("enter data n:"))
s = 1
s1 = 0
t = 1
For i = 1 To n
s = s * (x ^ i)
t = t * (i + 1)
s1 = s1 + s / t
Next i
Print s1
End Sub
第二个:
Private Sub Command1_Click()
Dim t As Double, i As Integer, s As Double, n As Integer, e As Double
Dim a() As Integer
n = Val(InputBox("enter data n:"))
ReDim a(n) As Integer
e = 1
t = 1
s = 1
a(1) = 1
For i = 1 To n
t = t * i
s = s + 1 / t
a(i + 1) = s
If a(i) - a(i + 1) < 0.0001 Then
Exit For
End If
Next i
For i = 1 To n
e = e + a(i)
Next i
Print e
End Sub
Private Sub Command1_Click()
Dim x As Integer, n As Integer, s As Double, s1 As Double, t As Double
Dim i As Integer, j As Integer
x = Val(InputBox("enter data x:"))
n = Val(InputBox("enter data n:"))
s = 1
s1 = 0
t = 1
For i = 1 To n
s = s * (x ^ i)
t = t * (i + 1)
s1 = s1 + s / t
Next i
Print s1
End Sub
第二个:
Private Sub Command1_Click()
Dim t As Double, i As Integer, s As Double, n As Integer, e As Double
Dim a() As Integer
n = Val(InputBox("enter data n:"))
ReDim a(n) As Integer
e = 1
t = 1
s = 1
a(1) = 1
For i = 1 To n
t = t * i
s = s + 1 / t
a(i + 1) = s
If a(i) - a(i + 1) < 0.0001 Then
Exit For
End If
Next i
For i = 1 To n
e = e + a(i)
Next i
Print e
End Sub
追问
不过,不知道对不对。没有打开VB
谢谢你,大神。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询