网络辞海>>vB中的斐波那契数列 前20项取值总和问题如题 谢谢了>>正文

vB中的斐波那契数列 前20项取值总和问题如题 谢谢了

斐波那契数列前三项分别是0、1、1,你只加了第二项或第三项 所以才会少1 Dim a&(20) a(1) = 0: a(2) = 1 For i = 3 To 20 a(i) = a(i - 2) + a(i - 1) b = a(i) + b Next i For i = 1 To 20 Print Right(Space(7) & a(i), 8); If i Mod 10 = 0 T...

斐波那契数列前三项分别是0、1、1,你只加了第二项或第三项 所以才会少1 Dim a&(20) a(1) = 0: a(2) = 1 For i = 3 To 20 a(i) = a(i - 2) + a(i - 1) b = a(i) + b Next i For i = 1 To 20 Print Right(Space(7) & a(i), 8); If i Mod 10 = 0 T...

Private Sub Command1_Click() Dim i As Integer Dim j As Integer Dim n(9) As Integer n(0) = 0 n(1) = 1 For i = 2 To 9 n(i) = n(i - 1) + n(i - 2) Next Open App.Path & "\FB.dat" For Output As #1 For i = 0 To 9 Write #1, "fib(" & i ...

Dim st As String = "" Dim a(100) a(1) = 0 : a(2) = 1 For i = 3 To 100 a(i) = a(i - 2) + a(i - 1) Next i For i = 1 To 100 st = st & a(i) & " " If i Mod 10 = 0 Then st = st & vbCrLf Next i TextBox6.Text = st

窗体上放一个文本框,并设置成多行属性,用来数列的输出 Private Sub command1_Click() Dim a%, b%, c%, d% a = 0 : b = 1 Text1.Text = "0" & vbCrLf & "1" & vbCrLf For d = 1 To 18 c = a + b a = b b = c Text1.Text = Text1.Text & c & vbCrL...

没有画图工具,在记事本里简单写了一个. 自己翻译成流程图吧 #include int main() { int a[20],sum=3; a[0]=1; a[1]=2; for(int i=2;i

单击窗体后在窗体上输出前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 稍改一下吧

Option Base 1 Dim a() Private Sub Command1_Click() n = Val(InputBox("输入N的值", "求斐波那契数列第N项的值")) ReDim a(n) a(1) = 1: a(2) = 1 For i = 3 To n a(i) = a(i - 1) + a(i - 2) Next Print "第"; n; "项的值是:"; a(n) End Sub

'百度 tonkeys 原创Private Sub Command1_Click() Text1.Text = Fibonacci2(20) '调用函数返回前20项Fibonacci数的偶数,在文件框中输出结果End Sub'返回前N项Fibonacci数的偶数Public Function Fibonacci2(N As Integer) As String Dim a As Int...

不对吧,fibonacci数列前面两项都是1哦