Dim num(9999), mycount As Integer Private Sub Form_Load() Me.Hide Open App.Path & "\in2.txt" For Input As #1 Open App.Path & "\out2.txt" For Output As #2 Input #1, mycount num(1) = 10 num(2) = -3 For i = 3 To mycount num(i) = num(i - 1) + num(i - 2) Next Print #2, num(mycount) Close #2 Close #1 End End Sub
Dim s() Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Input #1, n ReDim s(n) s(1) = 10 s(2) = -3 For i = 3 To n s(i) = s(i - 1) - s(i - 2) Next Print #2, s(n) 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 Input #1, c ReDim a(c) a(1) = 10 a(2) = -3 For i = 3 To c a(i) = a(i - 1) - a(i - 2) Next Print #2, a(c) Close #2 Close #1 End End Sub
Dim num(9999), mycount As Integer
回覆刪除Private Sub Form_Load()
Me.Hide
Open App.Path & "\in2.txt" For Input As #1
Open App.Path & "\out2.txt" For Output As #2
Input #1, mycount
num(1) = 10
num(2) = -3
For i = 3 To mycount
num(i) = num(i - 1) + num(i - 2)
Next
Print #2, num(mycount)
Close #2
Close #1
End
End Sub
Dim s()
回覆刪除Private Sub Form_Load()
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, n
ReDim s(n)
s(1) = 10
s(2) = -3
For i = 3 To n
s(i) = s(i - 1) - s(i - 2)
Next
Print #2, s(n)
Close
Close
End
End Sub
Bob程式錯誤:壞習慣n(9999)要改 & 題目沒看清楚
回覆刪除KiKi程式正確
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
Input #1, c
ReDim a(c)
a(1) = 10
a(2) = -3
For i = 3 To c
a(i) = a(i - 1) - a(i - 2)
Next
Print #2, a(c)
Close #2
Close #1
End
End Sub