vb循环结构计算s=1-1⼀2+ 1⼀3-1⼀4+……-1⼀100

2024-12-05 00:55:59
推荐回答(1个)
回答1:

sub test()
dim b as double
b = jisuan(100)
msgbox b
end sub

function JiSuan(a as double) as double
if a<=1 then
JiSuan=1
else if a mod 2=0 then
JiSuan=-1/a + jisuan (a-1)
else
JiSuan=1/a + jisuan(a-1)
end if
end function