1樓:匿名使用者
private sub command1_click()dim n as integer
dim sum as double
sum = 0
n = inputbox("請輸入n的值")for i = 1 to n
sum = sum + jiecheng(i)next i
print sum
end sub
public function jiecheng(byval n as integer) as double
dim jc as double
jc = 1
for i = 1 to n
jc = jc * i
next
jiecheng = jc
end function
2樓:聽不清啊
private sub command1_click()n = cint(inputbox("n="))t = 1
for i = 1 to n
t = t * i
s = s + t
next i
print "1!+2!+...+"; n; "!="; send sub
vb程式設計。輸入整數n,計算1!+2!+3!….+n!的值,並在窗體上輸出。要求分別用for,while 兩種迴圈實現
3樓:落葉l無情
dim i as integer, j as integerdim n as integer, sum as long, jc as long
n = inputbox("請輸入:") '如果是用文字框text1輸入,這裡改為 n=val(text1)
sum = 0
for i = 1 to n
jc = 1
for j=1 to i
jc = jc * j
next j
sum = sum + jc
next i
print sum
while:
dim i as integer, j as integerdim n as integer, sum as long, jc as long
n = inputbox("請輸入:")
sum = 0
i = 1
while i <= n
jc = 1
j = 1
while j <= i
jc = jc * j
j = j + 1
wend
sum = sum + jc
i = i + 1
wend
print sum
vb中1!+2!+3!+……n!的**怎麼寫
4樓:錢沒人也沒
function fun(n as long)dim i as long,sum as long ,j as long
sum=0
l=1for i=1 to n
l=1for j=1 to n
l=l*j
next
sum=sum+l
next
fun=sum
end function
5樓:
private sub command1_click()dim i as integer, j as integer, k as double, n as integer, sum as double
n = val(inputbox("n="))for i = 1 to n
k = 1
for j = 2 to i
k = k * j
next
sum = sum + k
next
print sum
end sub
vb程式設計:求1!+2!+3!+...+n!(n為任意正整數) 20
6樓:匿名使用者
'在窗體上加入一個command1控制元件,然後複製下面**,執行即可。
option explicit
private sub command1_click()dim i as long, j as long, k as long
dim s as long, a as longj = inputbox("請輸入一個正整數:")if j < 1 then
msgbox "出錯!"
exit sub
end if
for i = 1 to j
a = 1
for k = 1 to i
a = a * k
next
s = s + a
next
msgbox "1!+2!+3!+...+n!=" & send sub
7樓:檢靜杉
'放一個text控制元件,一個按鈕控制元件
'text控制元件中輸入你要的n
private sub command1_click()dim a as integer
dim s, b
a = val(text1.text)
s = 0
b = 1
for i = 1 to a
b = b * i
s = s + b
next
print "結果為:" & s
end sub
'樓上算的是n!,而不是1!+2!+3!+...+n!
8樓:匿名使用者
輸個1000進去,樓上兩位的都得溢位。
這個連結是討論版(不含原始碼):http://bbs.
bccn.net/viewthread.php?
原始碼在這個連結中
裡面有好多種不同方式實現的。
9樓:
vb課本上就有源**
1 輸出陣列元素 輸入正整數n(1n 10),再輸入陣列a的n個整數
include include include define n 10 void main int i,a n b n n scanf d n if n n n n srand unsigned int time null for i 0 i 輸入一個正整數n 1 include int main ...
vb程式設計題在文字框1中輸入整數n判斷其能否
console.writeline 請輸入一個整數 int n n int.parse console.readline if n 5 0 n 7 0 console.writeline n 能夠同時被5和7整除 console.read elsew console.writeline n 不能夠同...
補全程式c語言輸入整數n輸出高度為n的等邊
這樣 for j 0 jfor j 0 j 2 1 1 j printf printf 請輸入一個整數 scanf d n trangle n 注意事項 include void trangle n for j 1 j 2 i 1 j 每行星號數1,3,5,7,9,注意 上個for迴圈與這個for迴...