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 Print #2, L(n) Loop Close Close End End Sub
Function L(a) ans = 1 c = 1 For i = 1 To a ans = ans + c c = c + i Next L = ans End Function
這有很深的數學幾何學~口~
回覆刪除運用到維空間(!!)
學習:
http://zh.wikipedia.org/wiki/空间分割定理
http://zh.wikipedia.org/wiki/三維空間
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, x
Print #2, L(x, 3)
Loop
Close #2
Close #1
End
End Sub
Function L(n, k)
If k = 1 Or n = 0 Then
If k = 1 Then L = n + 1
If n = 0 Then L = 1
Else
L = L(n - 1, k) + L(n - 1, k - 1)
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
Do While Not EOF(1)
Input #1, n
Print #2, L(n)
Loop
Close
Close
End
End Sub
Function L(a)
ans = 1
c = 1
For i = 1 To a
ans = ans + c
c = c + i
Next
L = ans
End Function
柯佑、arro好,
回覆刪除兩個程式執行都正確。