下列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 |
推荐试卷