VB试题:编写函数fun,函数的功能是:求I 到a之间的偶数之积

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/23 00:19:31
VB试题:编写函数fun,函数的功能是:求I到a之间的偶数之积VB试题:编写函数fun,函数的功能是:求I到a之间的偶数之积VB试题:编写函数fun,函数的功能是:求I到a之间的偶数之积Private

VB试题:编写函数fun,函数的功能是:求I 到a之间的偶数之积
VB试题:编写函数fun,函数的功能是:求I 到a之间的偶数之积

VB试题:编写函数fun,函数的功能是:求I 到a之间的偶数之积
Private Sub fun()
if i mod 2 = 0 then
for x=i to a step 2
s=s*x
next x
else
for x=(i+1) to a step 2 then
s=s*x
next x
end if
试试看行不行吧

Public Function ssif(a As Integer) As Integer
dim i as integer ,s as integer
s=0
for i = 2 to a step 2
s= s*2
next i
End Function

Private Sub fun()
if i mod 2 = 0 then
for x=i to a step 2
s=s*x
next x
else
for x=(i+1) to a step 2 then
s=s*x
next x

Private Function Sum(ByVal i As Integer, ByVal a As Integer) As Integer
For int As Integer = i To a
If int Mod 2 = 0 Then
Sum = sum * int
End If
Next
End Function

Function fun(a As Double) As Double
a = Int(a)
If a > 1 Then fun = 2
For i = 4 To Int(a / 2) * 2 Step 2
fun = fun * i
Next
End Function