VB程序问题Option Explicit'这是老师给的答案:Private Sub Form_Click()Dim y As Single,x As Single,a As Single,i As Integerx = InputBox("输入x")a = 1 '递推公式,a0=1,ai=x*ai-1/i i>0y = a 'y用来保存运算结果i = 0 'i记录当前已

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 08:41:26
VB程序问题Option Explicit'这是老师给的答案:Private Sub Form_Click()Dim y As Single,x As Single,a As Single,i As Integerx = InputBox(0y = a 'y用来保存运算结果i = 0 'i记录当前已" />
x]oPǿ 7lPWyәJ4+ۉ4L{6@7 2Cayq6W~OO$ oɓ~ExkP?cI!,JQ9>4-3G$m80*{O*x o|H^>@"`AQ֥ x*[Ő:2G9SU]"Ism.29F >ლQjq7 x3>CR74m4̣aQ̿foܞn 97= iDho)lhh(Ѧ) 2U6~М|dو"ʂOp

VB程序问题Option Explicit'这是老师给的答案:Private Sub Form_Click()Dim y As Single,x As Single,a As Single,i As Integerx = InputBox("输入x")a = 1 '递推公式,a0=1,ai=x*ai-1/i i>0y = a 'y用来保存运算结果i = 0 'i记录当前已
VB程序问题
Option Explicit
'
这是老师给的答案:
Private Sub Form_Click()
Dim y As Single,x As Single,a As Single,i As Integer
x = InputBox("输入x")
a = 1 '递推公式,a0=1,ai=x*ai-1/i i>0
y = a 'y用来保存运算结果
i = 0 'i记录当前已经累加的项数
While a >= 0.00001 '判出条件
i = i + 1
a = a * x / i
y = y + a
Wend
Print "y="; y
End Sub
自己写的这个为什么不对?
Private Sub Form_Click()
Dim y As Single,x As Single,a As Single,i As Integer
x = InputBox("请输入x")
i = 0
a = 1
y = a
If a > 0.00001 Then
i = i + 1
a = a * x / i
y=y+a
end if
print y
end sub

VB程序问题Option Explicit'这是老师给的答案:Private Sub Form_Click()Dim y As Single,x As Single,a As Single,i As Integerx = InputBox("输入x")a = 1 '递推公式,a0=1,ai=x*ai-1/i i>0y = a 'y用来保存运算结果i = 0 'i记录当前已
你这个没有循环知道吗?假设输入一个数字3,你的程序过程是这样的:a=1,y=1,a=1>0.00001,然后进入if,执行里面的程序,结果y=1+1*3/1=4,好了完了跳出if,然后Print显示.