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 a = 0: b = 1 For i = 1 To n - 1 ans = a + b a = b b = ans Next Print #2, ans Close Close End End Sub
Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Dim x(13) As Integer Input #1, n x(0) = 0 x(1) = 1 For i = 2 To n x(i) = x(i - 1) + x(i - 2) Next i Print #2, x(n) Close #2 Close #1 End End Sub
Private Sub Form_Load() Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Dim x(100) As Integer Input #1, n x(0) = 0 x(1) = 1 For i = 2 To n x(i) = x(i - 1) + x(i - 2) Next i ans = x(n) Print #2, ans Close #2 Close #1 End End Sub
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, x Print #2, f(x) Close Close End End Sub Function f(a) If a <= 2 Then ans = 1 Else ans = f(a - 1) + f(a - 2) End If f = ans End Function
Function f(x) If x <= 2 Then f = 1 Else f = f(x - 1) + f(x - 2) End If End Function Private Sub Form_Load() Open App.Path & "\in.txt" For Input As 1 Open App.Path & "\out.txt" For Output As 2 Input #1, n Print #2, f(n) Close #2 Close #1 End End Sub
Function f(n) If n = 0 Then f = 0 If n = 1 Or n = 2 Then f = 1 If n > 2 Then f = f(n - 1) + f(n - 2) End If End Function
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 Print #2, f(n) Close #2 Close #1 End End Sub
try{ DataInputStream isr= new DataInputStream(new FileInputStream(file)); BufferedReader b = new BufferedReader(new InputStreamReader(isr)); FileOutputStream A = new FileOutputStream(Fo); OutputStreamWriter out = new OutputStreamWriter(A); //--- String S = b.readLine(); int s = Integer.parseInt(S); int A1=0,A2=1; int i; int ans = 0; for (i=1;i<=s-1;i++){ans=A1+A2;A1=A2;A2=ans;} out.write(String.valueOf(ans)); //--- out.close(); } catch(Exception e){} }
Private Sub Form_Load() Dim arr() As Integer Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Input #1, n ReDim arr(Val(n)) For i = 0 To n If i < 2 Then arr(0) = 0 arr(1) = 1 Else arr(i) = arr(i - 2) + arr(i - 1) End If Next i Print #2, arr(n) Close #2 Close #1 End End Sub
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 Print #2, f(n) Close #2 Close #1 End End Sub
Function f(n) If n = 0 Then f = 0 If n = 1 Or n = 2 Then f = 1 If n > 2 Then f = f(n - 2) + f(n - 1) End Function
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
a = 0: b = 1
For i = 1 To n - 1
ans = a + b
a = b
b = ans
Next
Print #2, ans
Close
Close
End
End Sub
Private Sub Form_Load()
回覆刪除Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Dim x(13) As Integer
Input #1, n
x(0) = 0
x(1) = 1
For i = 2 To n
x(i) = x(i - 1) + x(i - 2)
Next i
Print #2, x(n)
Close #2
Close #1
End
End Sub
Private Sub Form_Load()
回覆刪除Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Dim x(100) As Integer
Input #1, n
x(0) = 0
x(1) = 1
For i = 2 To n
x(i) = x(i - 1) + x(i - 2)
Next i
ans = x(n)
Print #2, ans
Close #2
Close #1
End
End Sub
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, x
Print #2, f(x)
Close
Close
End
End Sub
Function f(a)
If a <= 2 Then
ans = 1
Else
ans = f(a - 1) + f(a - 2)
End If
f = ans
End Function
Function f(x)
回覆刪除If x <= 2 Then
f = 1
Else
f = f(x - 1) + f(x - 2)
End If
End Function
Private Sub Form_Load()
Open App.Path & "\in.txt" For Input As 1
Open App.Path & "\out.txt" For Output As 2
Input #1, n
Print #2, f(n)
Close #2
Close #1
End
End Sub
Function f(n)
回覆刪除If n = 0 Then f = 0
If n = 1 Or n = 2 Then f = 1
If n > 2 Then
f = f(n - 1) + f(n - 2)
End If
End Function
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
Print #2, f(n)
Close #2
Close #1
End
End Sub
package work;
回覆刪除import java.io.*;
public class Work{
public static void main(String[] args) {
String file = "c:\\in.txt";
String Fo = "c:\\out.txt";
String in="0";
try{
DataInputStream isr= new DataInputStream(new FileInputStream(file));
BufferedReader b = new BufferedReader(new InputStreamReader(isr));
FileOutputStream A = new FileOutputStream(Fo);
OutputStreamWriter out = new OutputStreamWriter(A);
//---
String S = b.readLine();
int s = Integer.parseInt(S);
int A1=0,A2=1;
int i;
int ans = 0;
for (i=1;i<=s-1;i++){ans=A1+A2;A1=A2;A2=ans;}
out.write(String.valueOf(ans));
//---
out.close();
}
catch(Exception e){}
}
}
作者已經移除這則留言。
回覆刪除Private Sub Form_Load()
回覆刪除Dim arr() As Integer
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, n
ReDim arr(Val(n))
For i = 0 To n
If i < 2 Then
arr(0) = 0
arr(1) = 1
Else
arr(i) = arr(i - 2) + arr(i - 1)
End If
Next i
Print #2, arr(n)
Close #2
Close #1
End
End Sub
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
Print #2, f(n)
Close #2
Close #1
End
End Sub
Function f(n)
If n = 0 Then f = 0
If n = 1 Or n = 2 Then f = 1
If n > 2 Then f = f(n - 2) + f(n - 1)
End Function