Option Explicit
Private Sub form_click()
Dim fac() As Integer, N(3) As Integer
Dim i As Integer, j As Integer
N(1) = 48: N(2) = 50: N(3) = 65
For i = 1 To 3
Call factor(fac(), N(i))
Print N(i); "的质因子是:";
For j = 1 To UBound(fac)
Print fac(j);
Next j
Print
Next i
End Sub
Private Sub factor(F() As Integer, ByVal N As Integer)
Dim Idx As Integer, k As Integer
k = 2
Do Until N = 1
If N Mod k = 0 Then
Idx = Idx + 1
ReDim Preserve F(1 To Idx)
F(Idx) = k
N = N / k
Else
k = k + 1
End If
Loop
End Sub
N(1--3)的值你可以任意改哈
Dim n%, cs, i%
n = Text1
cs = "1": i = 2
Do
If n Mod i = 0 Then
n = n / i: cs = cs & "×" & i
Else
i = i + 1
End If
Loop While i < n: cs = cs & "×" & n
Option Explicit
Private Sub Command1_Click()
Dim n%, cs, i%
n = InputBox("", "", 36)
cs = n & "=1": i = 2
Do
If n Mod i = 0 Then
n = n / i: cs = cs & "×" & i
Else
i = i + 1
End If
Loop While i < n: cs = cs & "×" & n
MsgBox cs
End Sub
你可以追问我,这样的补充问题让我如何办,再写一段代码上来?实际只要改几行代码就行了,汗,当我没回答。
电脑方面的,不懂咦,回答不出来!