Multi-primary equations tend to use cyclic solution. In the process of discussing a problem with netizens (http://expert.9cbs.net/expert/topic/2607/2607772.xml?temp =.7494928) Solve. And will be divided into two cases of integer solution and non-negative integer solution, please advise.
Private submmand1_click () demonstration X1 X2 X3 X4 X5 = 10 integer solution text1.text = "" DIM Answer as stringanswer = getResult (5, 10, true) 'assignment DIM TEMPTEMP = Split (Answer, VBCRLF ) For i = 0 to ubound (temp) TEMP (i) = "Solution" & i 1 & ":" & VBTAB & TEMP (i) 'add indexnextanswer = JOIN (TEMP, VBCRLF) text1.text = "equation x1 X2 X3 X4 X5 = 10 A total of "& Ubound (TEMP) 1 &" Solution: "& Vbcrlf & Answer 'Show All Answer in Textbox
End subprivate sub fascist2_click () 'Demo X1 X2 X3 X4 X5 = 10 Non-negative Solution Text1.Text = "" Dim Answer As String
Answer = GetResult (5, 10, false) 'assignment DIM Temptemp = Split (Answer, VBCRLF) for i = 0 To Ubound (TEMP) TEMP (i) = "Solution" & I 1 & ":" & VBTAB & TEMP (i) 'add indexnextanswer = JOIN (TEMP, VBCRLF) text1.text = "Equation X1 X2 X3 X4 X5 = 10 Command" & Ubound (Split (Answer, VBCRLF)) 1 & "Non-Zero Integer Solution: "& Vbcrlf & Answer 'Show All Answer in Textbox
End Sub
Private Sub Command3_Click () 'Demo Soluble Situation Text1.Text = "" Dim Answer As String
Answer = getResult (5, 3, false) DIM TEMPTEMP = SPLIT (Answer, VBCRLF) for i = 0 to Ubound (TEMP) TEMP (i) = "Solution" & I 1 & ": & Vbtab & Temp (i NEXTANSWER = JOIN (TEMP, VBCRLF) text1.text = "Equation X1 X2 X3 X4 X5 = 3 A total of" & Ubound (Split (Answer, VBCRLF)) 1 & "Non-Zero Integer Solution:" & VBCRLF & Answerend Sub
'Analytic function Function GETRESULT (ByVal n As Integer, ByVal SUM As Integer, Optional allowzero As Boolean = True) As StringDim temp () As String, i As LongIf n = 2 Then' dimensional equation If allowzero = True ThenReDim temp (SUM ) For i = 0 to sum 'allow zerotemp (i) = "x1 =" & i & ", x2 =" & sum - inextget = join (TEMP, VBCRLF) ERASE TEMPELSEREDIM TEMP (1 to Sum - 1)' Forbid Zerofor i = 1 to sum - 1TEMP (i) = "x1 =" & I & ", x2 =" & sum - inextgetResult = JOIN (TEMP, VBCRLF) ERASE TEMPEND IF
END IFIF N> 2 THEN
IF allowzero = true kilim temp (sum) for i = sum to 0 step -1 'allow zerotemp (i) = Replace (GetResult (N - 1, I, True), VBCRLF, ", X" & n & "=" & SUM - I & VBCRLF) & ", X" & n & "=" & sum - inextgetResult = JOIN (TEMP, VBCRLF) ERASE TEMPELSEIF SUM