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, d
ans = 0 For i = 1 To n If n Mod i = 0 And i Mod d = 0 Then ans = ans + 1 Next i
Sub main() Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Do Until EOF(1) Input #1, a, b For i = 1 To a If a Mod i = 0 Then If i Mod b = 0 Then x = x + 1 End If Next Print #2, Trim(x) x = 0 Loop End Sub
Private Sub Form_Load() Dim ans 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, d If n Mod d = 0 Then ans = 1 Else ans = 0 For i = 2 To n / 2 If n Mod i = 0 Then If i Mod d = 0 Then ans = ans + 1 Next Print #2, ans Loop 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
Do While Not EOF(1)
Input #1, n, d
ans = 0
For i = 1 To n
If n Mod i = 0 And i Mod d = 0 Then ans = ans + 1
Next i
Print #2, ans
Loop
Close #2
Close #1
End
End Sub
Sub main()
回覆刪除Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Do Until EOF(1)
Input #1, a, b
For i = 1 To a
If a Mod i = 0 Then
If i Mod b = 0 Then x = x + 1
End If
Next
Print #2, Trim(x)
x = 0
Loop
End Sub
Private Sub Form_Load()
回覆刪除Dim ans
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, d
If n Mod d = 0 Then ans = 1 Else ans = 0
For i = 2 To n / 2
If n Mod i = 0 Then If i Mod d = 0 Then ans = ans + 1
Next
Print #2, ans
Loop
Close
Close
End
End Sub
佑, arro,lewis50093 好,
回覆刪除三個程式,arro的程式會比較好。
但是,三個都正確。