VB,求详细解答过程求N A B答案是10 27 9不知怎么的出来的
optionexplictdimnasintegerprivatesubcommand1_click()dimaasinteger,basintegera=2b=3for...
option explict dim n as integer private sub command1_click() dim a as integer,b as integer a=2b=3 for n=1 to 6 if n mod 2=0 then b=fun(n,a)+a else a=fun(b,n)+b end if next n print n,a,b end sub private function fun(x as integer,y as integer)as integer x=y-1+n y=x+y-n fun=x+y end function
展开
展开全部
参数值传给 fun(x,y) 时,参数的值会在fun(x,y)内修改,即在fun 函数内, x,y 就是你传递过来的参数,如
function fun(x as integer,y as integer) as as integer
x=1: y=2
fun=x+y
end function
Private Sub command1_click()
Dim a As Integer, b As Integer
a = 10
b = 10
c=fun(a,b)
print a,b,c
end sub
输出为 1 2 3
function fun(x as integer,y as integer) as as integer
x=1: y=2
fun=x+y
end function
Private Sub command1_click()
Dim a As Integer, b As Integer
a = 10
b = 10
c=fun(a,b)
print a,b,c
end sub
输出为 1 2 3
追问
如题,你这是答非所问
追答
拜托,你这是举例说明,原理一样的,这是最浅显的,好不
不然,你调出本地出口,按F8,逐语句运行,自己摸索得了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询