求VB 1!+2!+3!+.......7! 的源代码
来源:百度知道 编辑:UC知道 时间:2024/05/15 13:31:54
用While wend 写出 1!+2!+3!+.......7! 的源代码
2.用While wend 写出 +1! -2!+3!-4!+5!-6!+7!-8!+9!-10!的源代码
请尽量只用 While wend语句
2.用While wend 写出 +1! -2!+3!-4!+5!-6!+7!-8!+9!-10!的源代码
请尽量只用 While wend语句
问题1:
Private Sub Command1_Click()
Dim i%, j%, m%, x%
x = 0
While i < 7
i = i + 1
j = 0: m = 1
While j < i
j = j + 1
m = m * j
Wend
x = x + m
Wend
Print x
End Sub
问题二:
Private Sub Command1_Click()
Dim i%, j%, m%, n%, x%
x = 0: n = 1
While i < 7
i = i + 1
j = 0: m = 1
While j < i
j = j + 1
m = m * j
Wend
n = n * -1
x = x + m
Wend
Print x
End Sub
2!是什么意思?
求阶乘的函数
private function f(byval n as integer) as long
dim a as long
if n=0 then a=1
if n=1 then a=1
a=f(n-1)*n
f=a
end function
1.
dim b as long
dim i as integer
i=1
b=0
while i<=7
b=b+f(i)
i=i+1
wend
print b
2.
dim c as long
dim j as integer
dim k as integer
c=0
while i<=10
if i mod 2=0 then
k=-1