Dim number, ans 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 Input #1, num If num = 0 Then Exit Do ReDim number(num) Call rr(num) Print #2, ans Loop Close #2 Close #1 End End Sub
Public Function rr(ByVal k As Integer) If k = 1 Then rr = 0 If k = 2 Then rr = 1 If k > 2 Then rr = rr(k - 1) * 3 - rr(k - 2) ans = rr End Function
Dim ans As Integer 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, num Call a(Val(num)) Print #2, ans Loop Close #2 Close #1 End End Sub
Function a(b) If b = 0 Then End If b = 2 Then a = 1 If b = 3 Then a = 3 If b > 3 Then a = a(b - 1) * 3 - a(b - 2) ans = a End Function
Dim number, ans
回覆刪除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
Input #1, num
If num = 0 Then Exit Do
ReDim number(num)
Call rr(num)
Print #2, ans
Loop
Close #2
Close #1
End
End Sub
Public Function rr(ByVal k As Integer)
If k = 1 Then rr = 0
If k = 2 Then rr = 1
If k > 2 Then rr = rr(k - 1) * 3 - rr(k - 2)
ans = rr
End Function
Dim ans As Integer
回覆刪除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, num
Call a(Val(num))
Print #2, ans
Loop
Close #2
Close #1
End
End Sub
Function a(b)
If b = 0 Then End
If b = 2 Then a = 1
If b = 3 Then a = 3
If b > 3 Then a = a(b - 1) * 3 - a(b - 2)
ans = a
End Function