fibonacci數列 vb問題 急 明天要交作業了

2021-12-22 19:27:21 字數 574 閱讀 7127

1樓:

private sub command1_click()dim n%, fib() as longn = val(text1.text)

if n > 2 then

redim fib(1 to n)

fib(1) = 0: fib(2) = 1for i = 3 to n

fib(i) = fib(i - 1) + fib(i - 2)next i

text2.text = fib(n)

end if

end sub

2樓:

private sub form_click()dim a&(30)

a(1) = 0: a(2) = 1

for i = 3 to 30

a(i) = a(i - 2) + a(i - 1)next i

for i = 1 to 30

print right(space(7) & a(i), 8);

if i mod 10 = 0 then printnext i

end sub

幫忙用VB求解數列問題

dim i,j,t 20 total j 1for i 1 to 20 獲得從t 1 到t 20 的數值t i 3 j 3 等價於t i j j 1 j 2 j j 3 跨過三個數字 j j i 將沒用的數字帶過 next for i 1 to 20 求得總和,儲存到totaltotal total...

急急急 計算fibonacci數列前n項和,提示f(n)定義

在此借用一下夜遊神小翠的程式 include define n 20 int fibonacci int n void main printf n 只要修改巨集定義n的值,就可以輸出斐波那契數列的前n項。樓主有不會可以再問哦。include include define m sqrt 5 int m...

vb程式設計問題,VB程式設計問題

private sub command1 click text1 for i 1 to 45 7 for j 1 to 45 6 2for k 1 to 45 3 5if i j 2 k 5 45 thenn n 1 end if next next next text1 n end sub pri...