VB编程用循环结构求P=2*(-4)*6*(-8)*10*(-12)*14*(-16)*18*(-20)
2个回答
展开全部
P=3.715891E+09
将下列代码复制进窗体代码中,则可实现点击就求出P。
Private Sub Form_click()
Dim sum As Single
Dim item As Single
Dim i As Integer, n As Integer
sum = 1
item = 2
i = 1
Do While i <= 5
sum = item * (-(item + 2)) * sum
item = 4 + item
i = i + 1
Loop
Print "P="; sum
End Sub
可根据需要加入控件或其他代码。
将下列代码复制进窗体代码中,则可实现点击就求出P。
Private Sub Form_click()
Dim sum As Single
Dim item As Single
Dim i As Integer, n As Integer
sum = 1
item = 2
i = 1
Do While i <= 5
sum = item * (-(item + 2)) * sum
item = 4 + item
i = i + 1
Loop
Print "P="; sum
End Sub
可根据需要加入控件或其他代码。
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询