vb编程求解s=a!+b!+c!,其中阶乘的计算分别使用子过程和函数过程来实现,a,b,c的值从文本框中输入 10
3个回答
展开全部
Private Function JC(i As Integer) As Long
If i > 1 Then
JC = i * JC(i - 1)
Else
JC = 1
End If
End Function
Private Sub Command1_Click()
Print JC(Val(Text1.Text)) + JC(Val(Text2.Text)) + JC(Val(Text3.Text))
End Sub
i的范围自己控制一下
If i > 1 Then
JC = i * JC(i - 1)
Else
JC = 1
End If
End Function
Private Sub Command1_Click()
Print JC(Val(Text1.Text)) + JC(Val(Text2.Text)) + JC(Val(Text3.Text))
End Sub
i的范围自己控制一下
展开全部
Private Sub Command1_Click()
Dim s As Long
s = jiecheng(Val(Text1.Text)) + jiecheng(Val(Text2.Text)) + jiecheng(Val(Text3.Text))
Print s
End Sub
Private Function jiecheng(i As Integer) As Long
Dim m As Integer, n As Double
n = 1
For m = 1 To i
n = n * m
Next
jiecheng = n
End Function
Dim s As Long
s = jiecheng(Val(Text1.Text)) + jiecheng(Val(Text2.Text)) + jiecheng(Val(Text3.Text))
Print s
End Sub
Private Function jiecheng(i As Integer) As Long
Dim m As Integer, n As Double
n = 1
For m = 1 To i
n = n * m
Next
jiecheng = n
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
private function aa(a as integer)
s=1
For i = 2 To a
s = s * i
Next
aa=s
end sub
private sub command1_click()
s=aa(10)+aa(20)+aa(30)
print "s=" & s
end sub
s=1
For i = 2 To a
s = s * i
Next
aa=s
end sub
private sub command1_click()
s=aa(10)+aa(20)+aa(30)
print "s=" & s
end sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询