VB中用sub过程编程1!+2!+3!...+10!的代码,一定要是Sub过程
答案:2 悬赏:30 手机版
解决时间 2021-03-05 09:10
- 提问者网友:戎马万世
- 2021-03-04 10:44
VB中用sub过程编程1!+2!+3!...+10!的代码,一定要是Sub过程
最佳答案
- 五星知识达人网友:猎心人
- 2021-03-04 12:02
Private Sub jc(x As Integer, y As Single)
Dim i As Integer
y = 1
For i = 1 To x
y = y * i
Next i
End Sub
Private Sub Form_Click()
Dim j As Integer, s As Single, sum As Single
For j = 1 To 10
Call jc(j, s)
sum = sum + s
Next j
Print sum
End Sub
Dim i As Integer
y = 1
For i = 1 To x
y = y * i
Next i
End Sub
Private Sub Form_Click()
Dim j As Integer, s As Single, sum As Single
For j = 1 To 10
Call jc(j, s)
sum = sum + s
Next j
Print sum
End Sub
全部回答
- 1楼网友:掌灯师
- 2021-03-04 13:17
'阶乘和的结果
public result=0
'某个数阶乘值
public temp
'计算1~num的阶乘和
Sub start(num1)
For i=1 to num+1 Step + 1
temp=1
call then(i)
result = result + temp
Next
End Sub
'计算num2为数字的阶乘
Sub then(num2)
flag=0
If num2=0 or num2=1 Then
temp =temp*1
Else
temp =temp*(num2-1)
call then(num2-1)
End If
End Sub
public result=0
'某个数阶乘值
public temp
'计算1~num的阶乘和
Sub start(num1)
For i=1 to num+1 Step + 1
temp=1
call then(i)
result = result + temp
Next
End Sub
'计算num2为数字的阶乘
Sub then(num2)
flag=0
If num2=0 or num2=1 Then
temp =temp*1
Else
temp =temp*(num2-1)
call then(num2-1)
End If
End Sub
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯