题干

下列VB程序中,f是一个递归函数:(   )

Private Sub Command1_Click()

 Dim y As Integer

 y = Val(Text1.Text)

 Label1.Caption = Str(f(y))

End Sub

Function f(n As Integer) As Integer

 If (n = 1) Or (n = 2) Then

    f = 1

  Else

    f = f(n - 1) + f(n - 2)

  End If

End Function

程序运行时,在文本框中输入8,单击命令按钮Command1后,Label1中显示的内容是:

A:5

B:8

C:13

D:21

上一题 下一题 0.0难度 选择题 更新时间:2019-10-25 01:09:46

答案(点此获取答案解析)

D