vb求斐波那契数列
发布网友
发布时间:2022-12-16 08:45
我来回答
共2个回答
热心网友
时间:2024-11-24 17:22
求采纳~
Option Base 1
Private Sub Command1_Click()
Dim fibo()
i = Val(InputBox("输入i的值", "求斐波那契数列第i项的值"))
ReDim fibo(i)
fibo(1) = 1: fibo(2) = 1
For n = 3 To i
fibo(n) = fibo(n - 1) + fibo(n - 2)
Next
Print "第"; i; "项的值是:"; fibo(i)
End Sub
热心网友
时间:2024-11-24 17:23
单击窗体后在窗体上输出前20个斐波那契数(5个一行)
Private Sub Frm_click()
Dim f(20) as integer
F(1)=1
F(2)=1
For i=3 to 20
F(i)=f(i-2)+f(i-1)
Next i
For i=1 to 20
If i mod 5=0 then print
Print f(i);
Next i
End Sub
稍改一下吧
打字不易,如满意,望采纳。