1个回答
展开全部
1,
Dim a,b,i
a=Array(2,8,7,6,4,28,70,25)
b=Array(79,27,32,41,57,66,78,80)
Dim c(8)
For i=0 To Ubound(a)
c(i)=a(i)+b(i)
Next
2
1)Function
Function jc(a)
If a>0 Then
jc=a*jc(a-1)
Else
jc=1
End If
End Function
Dim s,a,b,c
a=4
b=7
c=5
s=jc(a)+jc(b)+jc(c)
2)Sub
Dim a,b,c,s
a=1
b=2
c=3
s=0
Sub jc(x)
Dim v
v=1
While x>0
v=v*x
x=x-1
Wend
s=s+v
End Sub
jc a
jc b
jc c
MsgBox s
另一种方法:
Function x(ByVal a As Integer, ByVal b As Integer, ByVal c As Integer)
suma = 1
sumb = 1
sumc = 1
For i = 1 To a
suma = suma * i
Next
For j = 1 To b
sumb = sumb * j
Next
For k = 1 To c
sumc = sumc * k
Next
x = suma + sumb + sumc
Print "调用Function过程时的输出结果:"
End Function
Private Sub Command1_Click()
Dim a(2) As Integer
For i = 0 To 2
a(i) = InputBox("输入第" & i + 1 & "个数")
Next
Print x(a(0), a(1), a(2))
End Sub
Sub y(ByVal a As Integer, ByVal b As Integer, ByVal c As Integer)
suma = 1
sumb = 1
sumc = 1
For i = 1 To a
suma = suma * i
Next
For j = 1 To b
sumb = sumb * j
Next
For k = 1 To c
sumc = sumc * k
Next
Sum = suma + sumb + sumc
Print "调用Sub过程时的输出结果:"
Print Sum
End Sub
Private Sub Command2_Click()
Dim a(2) As Integer
For i = 0 To 2
a(i) = InputBox("输入第" & i + 1 & "个数")
Next
y a(0), a(1), a(2)
End Sub
Dim a,b,i
a=Array(2,8,7,6,4,28,70,25)
b=Array(79,27,32,41,57,66,78,80)
Dim c(8)
For i=0 To Ubound(a)
c(i)=a(i)+b(i)
Next
2
1)Function
Function jc(a)
If a>0 Then
jc=a*jc(a-1)
Else
jc=1
End If
End Function
Dim s,a,b,c
a=4
b=7
c=5
s=jc(a)+jc(b)+jc(c)
2)Sub
Dim a,b,c,s
a=1
b=2
c=3
s=0
Sub jc(x)
Dim v
v=1
While x>0
v=v*x
x=x-1
Wend
s=s+v
End Sub
jc a
jc b
jc c
MsgBox s
另一种方法:
Function x(ByVal a As Integer, ByVal b As Integer, ByVal c As Integer)
suma = 1
sumb = 1
sumc = 1
For i = 1 To a
suma = suma * i
Next
For j = 1 To b
sumb = sumb * j
Next
For k = 1 To c
sumc = sumc * k
Next
x = suma + sumb + sumc
Print "调用Function过程时的输出结果:"
End Function
Private Sub Command1_Click()
Dim a(2) As Integer
For i = 0 To 2
a(i) = InputBox("输入第" & i + 1 & "个数")
Next
Print x(a(0), a(1), a(2))
End Sub
Sub y(ByVal a As Integer, ByVal b As Integer, ByVal c As Integer)
suma = 1
sumb = 1
sumc = 1
For i = 1 To a
suma = suma * i
Next
For j = 1 To b
sumb = sumb * j
Next
For k = 1 To c
sumc = sumc * k
Next
Sum = suma + sumb + sumc
Print "调用Sub过程时的输出结果:"
Print Sum
End Sub
Private Sub Command2_Click()
Dim a(2) As Integer
For i = 0 To 2
a(i) = InputBox("输入第" & i + 1 & "个数")
Next
y a(0), a(1), a(2)
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询