Dim a() Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Do While Not EOF(1) Input #1, n ReDim a(n) a(0) = 0 a(1) = 1 a(2) = 1 a(3) = 2 For i = 4 To n If Len(a(i - 1)) > Len(a(i - 2)) Then Do a(i - 2) = "0" & a(i - 2) Loop Until Len(a(i - 1)) = Len(a(i - 2)) End If For j = Len(a(i - 1)) To 1 Step -1 d = Val(Mid(a(i - 1), j, 1)) b = Val(Mid(a(i - 2), j, 1)) c = d + b + e e = 0 If c >= 10 And j <> 1 Then e = c \ 10 c = c Mod 10 End If a(i) = c & a(i) Next Next Print #2, a(n) Loop Close Close End End Sub
Dim a()
回覆刪除Private Sub Form_Load()
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Do While Not EOF(1)
Input #1, n
ReDim a(n)
a(0) = 0
a(1) = 1
a(2) = 1
a(3) = 2
For i = 4 To n
If Len(a(i - 1)) > Len(a(i - 2)) Then
Do
a(i - 2) = "0" & a(i - 2)
Loop Until Len(a(i - 1)) = Len(a(i - 2))
End If
For j = Len(a(i - 1)) To 1 Step -1
d = Val(Mid(a(i - 1), j, 1))
b = Val(Mid(a(i - 2), j, 1))
c = d + b + e
e = 0
If c >= 10 And j <> 1 Then
e = c \ 10
c = c Mod 10
End If
a(i) = c & a(i)
Next
Next
Print #2, a(n)
Loop
Close
Close
End
End Sub