拳皇用键盘玩的心得:帮我编VB程序题

来源:百度文库 编辑:高校问答 时间:2024/04/27 04:41:32
1。编写一个过程,求一个数的阶乘;
2。编写一个程序,计算1+2+3+、、、、、+100
3。编写一个过程,用来计算输出s=1+2分之一+3分之一+4分之一+、、、、、+100分之一

Option Explicit
'点击窗口即可运行
Private Sub Form_click()
Print jc(5)
Print jf()
Print s(2)
End Sub

Function jc(i As Integer) As Integer '函数jc JieCheng 阶乘
If i = 1 Then
jc = 1
Else
jc = jc(i - 1) * i
End If
End Function

Function jf() As Integer '函数jf JiaFa 加法
Dim i As Integer
jf = 0
For i = 1 To 100
jf = jf + i
Next i
End Function

Function s(j As Integer) As Double '函数s
Dim i As Integer
s = 1#
For i = 2 To j
s = s + 1 / i
Next i
End Function