'因數的次方表達處理2
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim a(20)
Dim qn = 720
Dim bqn = qn
Dim j = 0
For k = 2 To qn
While qn Mod k = 0
qn = qn / k
a(j) = k
j = j + 1
End While
Next
j = j - 1
ReDim Preserve a(j)
Dim str1 = ""
Dim p = 0
Dim n = 1
For i = 0 To a.Length - 1
Dim c = a(i)
If c <> p Then
If str1 = "" Then
str1 = str1 & c & "^"
Else
str1 = str1 & n & "*" & c & "^"
End If
n = 1
Else
n = n + 1
End If
p = c
Next
str1 = str1 & n
str1 = Replace(str1, "^1", "")
str1 = bqn & "=" & str1
MsgBox(str1)
End
End Sub
End Class
沒有留言:
張貼留言