1樓:展翅東南飛
先定義一個遞迴函式f(x): if x>0 return f(x)*f(x-1) if x=0 return x=1
然後再把你上面的式子用個迴圈加起來就行了 vb的具體語法我忘了 上面就說個大概意思
2樓:
100的階乘是天文數字,vb算不出來
3樓:匿名使用者
private sub command1_click()print sf(100)
end sub
private function sf(byval n as integer) as double
dim i as integer
dim f as double
dim s as double
s = 0
f = 1
for i = 1 to n
f = f * i
s = s + f
next i
sf = s
end function
4樓:不配愛配角
private sub command1_click()j = 1j=1for i = 1 to 100
j = j * i
y = y + j
next i
print y
end sub
5樓:匿名使用者
難點在資料處理,,好大的說
用vb求1!+2!+3!+……+10!的結果。
6樓:匿名使用者
樓上有幾個錯誤!定義的整型變數數值或溢位,最後一行的標籤也輸錯了!回我已改正,並已執行無誤
答private sub command1_click()dim i as integer
dim sum as long
dim n as long
n = 1
sum = 0
for i = 1 to 10
n = n * i
sum = sum + n
next
label1.caption = sum
end sub
7樓:匿名使用者
dim n%,sum%,i%
n = 1
sum = 0
for i = 1 to 10
n = n * i
sum = sum+n
next
label1.caption=cstr(sum)
8樓:匿名使用者
dim i as integer
dim sum as integer
dim n as integer
n = 1
sum = 0
for i = 1 to 10
n = n * i
sum = sum + n
next
lebel1.caption=cstr(sum)
9樓:匿名使用者
private sub command1_click()dim sum as long
for i = 1 to 10
sum = sum + jc(i)
next
me.label1.caption = sumend sub
private function jc(byval i as integer) as long
dim j as integer, cj as longcj = 1
for j = 1 to i
cj = cj * j
next
jc = cj
end function
用vb程式設計計算:1!+2!+3!+4!+…+n!
10樓:匿名使用者
新建一個工程,新增個命令按鈕和一個文字框
**如下:
private sub command1_click()n = val(text1.text)
s = 0 '存結果
for i = 1 to n
t = 1 '臨時存積的變數
for j = 1 to i '計算階乘
t = t * j
next j
s = s + t
next i
print "結果為:" & s
end sub
c語言程式設計求1+2+3+4+...+100。 15
11樓:會飛的小兔子
#include"stdio.h"
intsum(intn)
returnsum;
}voidmain(void)
擴充套件資料c語言1、2、3、4組成互不相同且無重複數字#include"stdio.h"
#include"conio.h"
main()
system("pause");//螢幕列印保持}
12樓:鍾恪
#include
void main()
13樓:匿名使用者
數字在計算機裡是用2進位制的形勢表示的,其中又分為正數和負數,正數就是正數,負數是通過補碼的形勢儲存的。轉換方法就是將該負數對應的正數(二進位制)取反再加1。編寫程式的時候,你在定義整數的時候按照你的環境的不同會定義成8位16位32位64位的整數(二進位制)。
當這些整數相加的結果超過了它能表示的範圍之後,就會產生資料的溢位。補碼(負數)的起始位都是1,正數的全是0。當加過了就把前面應該是0的位寫成了1。
就是說正數變成了負數...不知道這麼解釋你明白不?
14樓:匿名使用者
#include
int main()
15樓:匿名使用者
main()
printf("sum=%d\n",sum);}
16樓:己優翁憶雪
#include
main()
printf("%d",s);}
vb程式設計計算:1+2!+3!+...+10!
17樓:匿名使用者
private sub command1_click()dim i as integer, j as integerdim l as long, h as longfor i = 1 to 10
h = 1
for j = 1 to i
h = h * j
next
l = l + h
next
print l
end sub
18樓:岔路程式緣
private sub form_click()
form1.autoredraw = true
me.show
dim sum as long, i as integer, j as integer
sum = 0
for i = 1 to 10
sum = sum + jc(i)
next
print "s=1+2!+3!+...+10!="; sum
end sub
private function jc(x as integer) as long
if x = 1 then jc = 1 else jc = x * jc(x - 1)
end function
或(do while loop ):
private sub form_click()
form1.autoredraw = true
me.show
dim sum as long, i as integer, j as integer
sum = 0
i=1do while i <= 10
sum = sum + jc(i)
i=i+1
loop
print "s=1+2!+3!+...+10!="; sum
end sub
private function jc(x as integer) as long
if x = 1 then jc = 1 else jc = x * jc(x - 1)
end function
19樓:亓靖瀅
dim i as integer
dim sum as integer
dim n as integer
n = 1
sum = 0
for i = 1 to 10
n = n * i
sum = sum + n
next
print(sum)
20樓:宿思敏羿宣
vb程式設計計算2+2^1+2^2+2^3+......+2^10private
subcommand1_click()
dimi%,s%s
=2fori=1
to10s=
s+2^
inext
iprint
send
subvb程式設計求出100-200以內的同時能被3和5整除的所有整數private
subcommand1_click()
dimi
asinteger
fori
=100
to200ifi
mod3=0
andi
mod5=0
then
i;end
ifnext
iend
subvb程式設計計算1-2+3-4+5-6……+-n,其中n由文字框輸入
private
subcommand1_click()
dimi%,
k%,s%k=
1fori=
1toval(text1.text)s=
s+i*
kk=-k
next
iprint
sendsub
vb程式設計求1+2+3+4+……+100的值怎麼編
21樓:匿名使用者
dim i as integer,n as integerfor i=1 to 100
n=n+i
next
print n
急求一道vb程式設計題答案求幫忙,急求一道VB程式設計題答案!!!!!求幫忙!!!!
sub mand1 dim tmp as string dim arr tmp text1.text tmp replace tmp,預防中英文 混淆 if instr tmp,0 then msgbox 您輸入的格式不對!請重新輸入,要求有區回號 exit sub end if arr split...
VB程式設計題目,vb程式設計題目
private sub command1 click dim k sum sum 0 k val trim inputbox 請輸入正整數k的值 for i 1 to len str k sum sum val mid str k i,1 next i msgbox sum end subpriva...
VB作業急求VB高手指點迷津,vb作業 急求VB高手!!!!!!!!!!!!!
完全照你圖做的 private sub command1 click dim a as integer print 1000以內的完數 for i 6 to 1000 s 0 n 0 t for j 1 to i 1 if i mod j 0 then s s j n n 1 redim prese...