level 4
蓝胖子嘿嘿1
楼主
找一个正整数的所有质因子。
请问这段代码哪里有问题?需要修改
Option Explicit
Private Sub Form_Click()
Dim x As Integer, i As Integer, k As Integer, j As Integer
Dim a() As Integer
x = InputBox("输入正整数x=")
i = 2
Do While x > i
If x Mod i = 0 Then
k = k + 1
ReDim a(k)
a(k) = i
x = x \ i
Else
i = i + 1
End If
Loop
Print x; "的质因数为:";
For j = 1 To UBound(a)
Print a(j);
Next j
End Sub
2020年05月07日 01点05分
1
请问这段代码哪里有问题?需要修改
Option Explicit
Private Sub Form_Click()
Dim x As Integer, i As Integer, k As Integer, j As Integer
Dim a() As Integer
x = InputBox("输入正整数x=")
i = 2
Do While x > i
If x Mod i = 0 Then
k = k + 1
ReDim a(k)
a(k) = i
x = x \ i
Else
i = i + 1
End If
Loop
Print x; "的质因数为:";
For j = 1 To UBound(a)
Print a(j);
Next j
End Sub