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 a, n, i As Long Input #1, n n = Val(n) a = 1 i = 0 For i = 1 To n a = a * i Next 'MsgBox a j = Len(a) i = 0 For i = j - 1 To 0 Step -1 q = Mid(a, i, 1) If Val(q) <> 0 Then Exit For Next Print #2, q 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 b = 1 For i = n To 1 Step -1
If b > 10000 Then b = b Mod 10000 b = b * i Do While b Mod 10 = 0 And b \ 10 > 1 b = b \ 10 Loop
Next Print #2, Right(b, 1) 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 a, n, i As Long Input #1, n n = Val(n) a = 1 For i = 1 To n a = a * i s = Len(a) For j = s To 1 Step -1 p = Mid(a, j, 1) If p <> 0 Then a = Mid(a, j, 1) Exit For End If Next Next Print #2, a Close #2 Close #1 End End Sub
Private Sub Form_Load() Me.Hide Open "in.txt" For Input As #1 Open "out.txt" For Output As #2 Input #1, a k = 1 For i = 2 To a k = k * i Do c = k Mod 10 k = k \ 10 Loop Until c <> 0 k = c Next i Print #2, k End End Sub
Dim txt As Long
回覆刪除Dim ans As String
Private Sub Form_Load()
Open App.Path & "\in.txt" For Input As #1
Input #1, txt
Close #1
Sum = 1
If txt > 0 And txt < 10000 Then
For i = 1 To txt
Sum = Sum * i
For ii = 0 To Len(Sum) - 1
If Not Mid(Sum, Len(Sum) - ii, 1) = "0" Then
ans = Mid(Sum, Len(Sum) - ii, 1)
Sum = ans
Exit For
End If
Next
Next
End If
For ii = 0 To Len(Sum) - 1
If Not Mid(Sum, Len(Sum) - ii, 1) = "0" Then
ans = Mid(Sum, Len(Sum) - ii, 1)
Exit For
End If
Next
MsgBox Sum
Open App.Path & "\out.txt" For Output As #2
Print #2, ans
Close #2
End Sub
哈囉:D
回覆刪除以後程式裡如果有自己測試輸出的程式碼的話,再PO答案之前要先註解調喔
ex:'MsgBox Sum
恩
回覆刪除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 a, n, i As Long
Input #1, n
n = Val(n)
a = 1
i = 0
For i = 1 To n
a = a * i
Next
'MsgBox a
j = Len(a)
i = 0
For i = j - 1 To 0 Step -1
q = Mid(a, i, 1)
If Val(q) <> 0 Then Exit For
Next
Print #2, q
Close #2
Close #1
End
End Sub
復陞好,輸入檔為9999時會溢位,想辦法除錯看看:)
回覆刪除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
b = 1
For i = n To 1 Step -1
If b > 10000 Then b = b Mod 10000
b = b * i
Do While b Mod 10 = 0 And b \ 10 > 1
b = b \ 10
Loop
Next
Print #2, Right(b, 1)
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 a, n, i As Long
Input #1, n
n = Val(n)
a = 1
For i = 1 To n
a = a * i
s = Len(a)
For j = s To 1 Step -1
p = Mid(a, j, 1)
If p <> 0 Then
a = Mid(a, j, 1)
Exit For
End If
Next
Next
Print #2, a
Close #2
Close #1
End
End Sub
Private Sub Form_Load()
回覆刪除Me.Hide
Open "in.txt" For Input As #1
Open "out.txt" For Output As #2
Input #1, a
k = 1
For i = 2 To a
k = k * i
Do
c = k Mod 10
k = k \ 10
Loop Until c <> 0
k = c
Next i
Print #2, k
End
End Sub