首页 > 其它 > 题目详情
【vb求n的阶乘n】
题目内容:
vb求n的阶乘n优质解答
Private Sub Command1_Click()
Dim i, j, k
For i = 1 To 10
k = 1
For j = 1 To i
k = k * j
Next
Print i & "!=" & k
Next
End Sub - 追问:
- 如果用inputbox呢
- 追答:
- Private Sub Command1_Click() Dim i, j, k i = Val(InputBox("输入一个数:", , 10)) '假设为一有效数字,未作错误判断 For i = 1 To 10 k = 1 For j = 1 To i k = k * j Next Print i & "!=" & k Next End Sub
优质解答
Dim i, j, k
For i = 1 To 10
k = 1
For j = 1 To i
k = k * j
Next
Print i & "!=" & k
Next
End Sub
- 追问:
- 如果用inputbox呢
- 追答:
- Private Sub Command1_Click() Dim i, j, k i = Val(InputBox("输入一个数:", , 10)) '假设为一有效数字,未作错误判断 For i = 1 To 10 k = 1 For j = 1 To i k = k * j Next Print i & "!=" & k Next End Sub
本题链接: