Private Sub Form_Load() Open App.Path & "/in.txt" For Input As #1 Open App.Path & "/out.txt" For Input As #2 Dim num(20) As Long num(1) = 1 For I = 2 To 20 num(I) = num(I - 1) * 3 - num(I - 2) Next I Do Input #1, x If x = 0 Then Exit Sub Print #2, num(x - 1)
D im A(100) As Long Private Sub Form_Load() Open App.Path & "/in.txt" For Input As #1 Open App.Path & "/out.txt" For Output As #2 A(1) = 0: A(2) = 1 Do While Not EOF(1) Input #1, x For i = 3 To x A(i) = A(i - 1) * 3 - A(i - 2) Next i If x = "0" Then Exit Sub Print #2, A(x) Loop Close #2 Close #1 End Sub
Dim a(24) As Long Private Sub Form_Load() Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 a(1) = 0 a(2) = 1 For i = 3 To 24 a(i) = a(i - 1) * 3 - a(i - 2) Next i Do Input #1, x If x = 0 Then Exit Do Print #2, a(x) Loop Close #1 Close #2 End Sub
Dim a(100) As Long Private Sub Form_Load() Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 a(1) = 0: a(2) = 1 For i = 3 To 25 a(i) = a(i - 1) + a(i - 2) Next i Do Input #1, x If x = 0 Then Exit Do c = x * 2 - 1 Print a(c) Loop Close #2 Close #1 End Sub
Dim a(100) As Long Private Sub Form_Load() Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 a(1) = 0: a(2) = 1 For i = 3 To 25 a(i) = a(i - 1) + a(i - 2) Next i Do Input #1, x If x = 0 Then Exit Do c = x * 2 - 1 Print #2, a(c) Loop Close #2 Close #1 End Sub
Private Sub Form_Load()
回覆刪除Open App.Path & "/in.txt" For Input As #1
Open App.Path & "/out.txt" For Input As #2
Dim num(20) As Long
num(1) = 1
For I = 2 To 20
num(I) = num(I - 1) * 3 - num(I - 2)
Next I
Do
Input #1, x
If x = 0 Then Exit Sub
Print #2, num(x - 1)
Loop
Close #2
Close #1
End Sub
D im A(100) As Long
回覆刪除Private Sub Form_Load()
Open App.Path & "/in.txt" For Input As #1
Open App.Path & "/out.txt" For Output As #2
A(1) = 0: A(2) = 1
Do While Not EOF(1)
Input #1, x
For i = 3 To x
A(i) = A(i - 1) * 3 - A(i - 2)
Next i
If x = "0" Then Exit Sub
Print #2, A(x)
Loop
Close #2
Close #1
End Sub
Dim a(24) As Long
回覆刪除Private Sub Form_Load()
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
a(1) = 0
a(2) = 1
For i = 3 To 24
a(i) = a(i - 1) * 3 - a(i - 2)
Next i
Do
Input #1, x
If x = 0 Then Exit Do
Print #2, a(x)
Loop
Close #1
Close #2
End Sub
Y揚、高仔、阿瑋好,
回覆刪除這題也因為討論過,程式是都沒問題。
不過,你們也都說月考到了,一次又post這麼多題,什麼時候做啊?
哈。
Dim a(100) As Long
回覆刪除Private Sub Form_Load()
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
a(1) = 0: a(2) = 1
For i = 3 To 25
a(i) = a(i - 1) + a(i - 2)
Next i
Do
Input #1, x
If x = 0 Then Exit Do
c = x * 2 - 1
Print a(c)
Loop
Close #2
Close #1
End Sub
Dim a(100) As Long
回覆刪除Private Sub Form_Load()
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
a(1) = 0: a(2) = 1
For i = 3 To 25
a(i) = a(i - 1) + a(i - 2)
Next i
Do
Input #1, x
If x = 0 Then Exit Do
c = x * 2 - 1
Print #2, a(c)
Loop
Close #2
Close #1
End Sub