题型:综合题 题类:常考题 难易度:普通
浙教版高一信息技术 专题五:VB程序设计
Private Sub Command1_Click()
Dim n As Long,k As Integer
Dim f1 As Long,f2 As Long,f As Long
If n>=20 Or n<=0 Then
Label2.Caption=”输入的数据有误”
Else
If n<=2 Then ‘第1,2个元素的值都为1
f=1
Else
f1=1
f2=1
For k=3 To n
f=f1+f2
f1=f2
f2=f
Next k
End If
Label2.Caption = ”斐波那契数列第” + Str(n) + ”项的值为” +
End If
End Sub
试题篮