C# 高斯消元項目運用

C# 高斯消元項目運用

最近項目涉及到一個需求,須要把指定數量的多個商品,混合裝入到多個不一樣型號的箱子中(每種型號的箱子裝入商品的種類和個數是固定的)。這就涉及到解多元一次方程

  • 針對多元一次方程通常用高斯消元去處理,當消元后仍有不能消掉的元 則須要解多元一次方程

1. 將數據轉換爲二維數組,消元代碼以下

  • 樣本數據以下

| 2, 3, 4, 3, 21 | => | 2, 3, 4, 3, 21 | => | 2, 3, 4, 3 , 21 | <br/> | 3, 1, 6, 2, 17 | => | 0, 7, 0, 5, 29 | => | 0, 7, 0, 5 , 29 | <br/> | 1, 3, 2, 1, 12 | => | 0, -3,0, 1, -3 | => | 0, 0, 0, -22, -66 | <br/>html


<div style="font-family: Arial; font-size: 13; color: gainsboro; background: #1e1e1e;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">rowLength</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">GetLength</span><span class="punctuation">(</span><span class="number" style="color:#b5cea8;">0</span><span class="punctuation">);</span><span class="comment" style="color:#57a64a;">//行數</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">colLength</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">GetLength</span><span class="punctuation">(</span><span class="number" style="color:#b5cea8;">1</span><span class="punctuation">);</span><span class="comment" style="color:#57a64a;">//列數</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">mainCol</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colLength</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">)</span>&nbsp;<span class="comment" style="color:#57a64a;">//按照列,一列一列的消元</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">mainRow</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">;</span>&nbsp;<span class="comment" style="color:#57a64a;">//主元行=主元列</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">row</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainRow</span>&nbsp;<span class="operator" style="color:#b4b4b4;">+</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">row</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">rowLength</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">row</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">)</span>&nbsp;<span class="comment" style="color:#57a64a;">//&nbsp;從主元的下一行開始&nbsp;行循環</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">row</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&gt;=</span>&nbsp;<span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">colLength</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">))</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">break</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment" style="color:#57a64a;">/*<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;n1*X&nbsp;+&nbsp;n2*Y&nbsp;=&nbsp;a&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m1*X&nbsp;+&nbsp;m2*Y&nbsp;=&nbsp;b&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&gt;&nbsp;&nbsp;n1*m1*X&nbsp;+&nbsp;n2*m1Y&nbsp;=&nbsp;a*m1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&gt;&nbsp;&nbsp;m1*n1*X&nbsp;+&nbsp;m2*n1*Y&nbsp;=&nbsp;b*n1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment" style="color:#57a64a;">//若是主元參數爲0(&nbsp;找出此列不爲0的行)&nbsp;運用行相加&nbsp;&nbsp;變換0參數</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">mainRow</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">rowi</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainRow</span>&nbsp;<span class="operator" style="color:#b4b4b4;">+</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">rowi</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">rowLength</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">rowi</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">rowi</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">!=</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">colj</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colj</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colLength</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colj</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">mainRow</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colj</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">+=</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">rowi</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colj</span><span class="punctuation">];</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">break</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">continue</span><span class="punctuation">;</span>&nbsp;<span class="comment" style="color:#57a64a;">//當前行&nbsp;此列已是0&nbsp;繼續消元下一行</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">m</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - method name - (TRANSIENT)">GetMinCommonMultiple</span><span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">],</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">]);</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">factorMain</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">m</span>&nbsp;<span class="operator" style="color:#b4b4b4;">/</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">];</span><span class="comment" style="color:#57a64a;">//主列的因子&nbsp;&nbsp;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">factor</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">m</span>&nbsp;<span class="operator" style="color:#b4b4b4;">/</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">];</span>&nbsp;<span class="comment" style="color:#57a64a;">//待消元列因子</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">colk</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colk</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colLength</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colk</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colk</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colk</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">*</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">factorMain</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colk</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">*</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">factor</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span></div>數組

2. 消元后,找出仍然沒法消除的元,解一元屢次不定方程

  • 經過消元 最終能夠肯定 a[3]=3 ,a[1]=2 a[0]和a[2]解有多個 須要解不定方程思路是將 多元方程切割成二元方程而後窮舉求解。 列入3x+2y+4z+6a=18, 令 w=2y+4z+6a,再令 2w=2(y+2z+3a) ,帶入公式 得 3x+2w=16,窮舉求出一個解 x=2 w=6 ,而後 再解 y+2z+3a=6。 一樣的方法再次處理
  • 代碼以下

<div style="font-family: Arial; font-size: 13; color: gainsboro; background: #1e1e1e;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&lt;</span><span class="xml doc comment - name" style="color:#608b4e;">summary</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;解不定方程</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&lt;/</span><span class="xml doc comment - name" style="color:#608b4e;">summary</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">public</span>&nbsp;<span class="keyword" style="color:#569cd6;">static</span>&nbsp;<span class="keyword" style="color:#569cd6;">bool</span>&nbsp;<span class="method name">ResoveIndefiniteEquation</span><span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span><span class="punctuation">[]</span>&nbsp;<span class="parameter name">arr</span><span class="punctuation">,</span>&nbsp;<span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="parameter name">value</span><span class="punctuation">,</span>&nbsp;<span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="parameter name">startIndex</span><span class="punctuation">,</span>&nbsp;<span class="keyword" style="color:#569cd6;">ref</span>&nbsp;<span class="keyword" style="color:#569cd6;">int</span><span class="punctuation">[]</span>&nbsp;<span class="parameter name">result</span><span class="punctuation">,</span>&nbsp;<span class="keyword" style="color:#569cd6;">ref</span>&nbsp;<span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="parameter name">count</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - parameter name - (TRANSIENT)">count</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">;</span><span class="comment" style="color:#57a64a;">//遞歸計數,防止無限遞歸</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">arr</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="keyword" style="color:#569cd6;">null</span>&nbsp;<span class="operator" style="color:#b4b4b4;">||</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - property name - (TRANSIENT)">Length</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">return</span>&nbsp;<span class="keyword" style="color:#569cd6;">false</span><span class="punctuation">;</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - property name - (TRANSIENT)">Length</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">reValue</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">value</span>&nbsp;<span class="operator" style="color:#b4b4b4;">/</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="number" style="color:#b5cea8;">0</span><span class="punctuation">];</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">value</span>&nbsp;<span class="operator" style="color:#b4b4b4;">%</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="number" style="color:#b5cea8;">0</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&amp;&amp;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">reValue</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&gt;=</span>&nbsp;<span class="constant name - identifier - (TRANSIENT)">MinResove</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&amp;&amp;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">reValue</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;=</span>&nbsp;<span class="constant name - identifier - (TRANSIENT)">MaxResove</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - parameter name - (TRANSIENT)">result</span><span class="punctuation">[</span><span class="identifier - parameter name - (TRANSIENT)">startIndex</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">reValue</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">return</span>&nbsp;<span class="keyword" style="color:#569cd6;">true</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">return</span>&nbsp;<span class="keyword" style="color:#569cd6;">false</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment" style="color:#57a64a;">//獲取第二部分元的最大公約數</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">commonDivisor</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="number" style="color:#b5cea8;">1</span><span class="punctuation">];</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;</span>&nbsp;<span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - property name - (TRANSIENT)">Length</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">);</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - local name - (TRANSIENT)">commonDivisor</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - method name - (TRANSIENT)">GetCommonDivisor</span><span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">commonDivisor</span><span class="punctuation">,</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">+</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">]);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="constant name - identifier - (TRANSIENT)">MinResove</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;=</span>&nbsp;<span class="constant name - identifier - (TRANSIENT)">MaxResove</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">currValue</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">value</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">*</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="number" style="color:#b5cea8;">0</span><span class="punctuation">];</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">currValue</span>&nbsp;<span class="operator" style="color:#b4b4b4;">%</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">commonDivisor</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">newArr</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="keyword" style="color:#569cd6;">new</span>&nbsp;<span class="keyword" style="color:#569cd6;">int</span><span class="punctuation">[</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - property name - (TRANSIENT)">Length</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">];</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Array</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">Copy</span><span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">,</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">newArr</span><span class="punctuation">,</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">,</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - property name - (TRANSIENT)">Length</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">);</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - parameter name - (TRANSIENT)">result</span><span class="punctuation">[</span><span class="identifier - parameter name - (TRANSIENT)">startIndex</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">currArr</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - method name - (TRANSIENT)">ResoveIndefiniteEquation</span><span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">newArr</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">currValue</span><span class="punctuation">,</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">startIndex</span>&nbsp;<span class="operator" style="color:#b4b4b4;">+</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">,</span>&nbsp;<span class="keyword" style="color:#569cd6;">ref</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">result</span><span class="punctuation">,</span>&nbsp;<span class="keyword" style="color:#569cd6;">ref</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">count</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">currArr</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">return</span>&nbsp;<span class="keyword" style="color:#569cd6;">true</span><span class="punctuation">;</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">count</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&gt;</span>&nbsp;<span class="number" style="color:#b5cea8;">1000000</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">&quot;遞歸太深沒法求解&quot;</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">return</span>&nbsp;<span class="keyword" style="color:#569cd6;">false</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">return</span>&nbsp;<span class="keyword" style="color:#569cd6;">false</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span></div>ide

3.完整代碼

<div style="font-family: Arial; font-size: 13; color: gainsboro; background: #1e1e1e;">&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">public</span>&nbsp;<span class="keyword" style="color:#569cd6;">class</span>&nbsp;<span class="class name" style="color:#4ec9b0;">GaussHelper</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&lt;</span><span class="xml doc comment - name" style="color:#608b4e;">summary</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;不定方程解的最小值</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&lt;/</span><span class="xml doc comment - name" style="color:#608b4e;">summary</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">private</span>&nbsp;<span class="keyword" style="color:#569cd6;">const</span>&nbsp;<span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="constant name">MinResove</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">;</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&lt;</span><span class="xml doc comment - name" style="color:#608b4e;">summary</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;不定方程解的最大值</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&lt;/</span><span class="xml doc comment - name" style="color:#608b4e;">summary</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">private</span>&nbsp;<span class="keyword" style="color:#569cd6;">const</span>&nbsp;<span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="constant name">MaxResove</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="number" style="color:#b5cea8;">100</span><span class="punctuation">;</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&lt;</span><span class="xml doc comment - name" style="color:#608b4e;">summary</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;利用高斯消元求解一元屢次方程組</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&lt;/</span><span class="xml doc comment - name" style="color:#608b4e;">summary</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&lt;</span><span class="xml doc comment - name" style="color:#608b4e;">param</span><span class="xml doc comment - attribute name" style="color:#c8c8c8;">&nbsp;name</span><span class="xml doc comment - delimiter" style="color:#608b4e;">=</span><span class="xml doc comment - attribute quotes" style="color:#c8c8c8;">&quot;</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="xml doc comment - attribute quotes" style="color:#c8c8c8;">&quot;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;&lt;/</span><span class="xml doc comment - name" style="color:#608b4e;">param</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">public</span>&nbsp;<span class="keyword" style="color:#569cd6;">static</span>&nbsp;<span class="keyword" style="color:#569cd6;">int</span><span class="operator" style="color:#b4b4b4;">?</span><span class="punctuation">[]</span>&nbsp;<span class="method name">ResoveGauss</span><span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span><span class="punctuation">[,]</span>&nbsp;<span class="parameter name">arr</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">arr</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="keyword" style="color:#569cd6;">null</span><span class="punctuation">)</span>&nbsp;<span class="keyword" style="color:#569cd6;">throw</span>&nbsp;<span class="keyword" style="color:#569cd6;">new</span>&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">ArgumentNullException</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">&quot;arr&quot;</span><span class="punctuation">);</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">rowLength</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">GetLength</span><span class="punctuation">(</span><span class="number" style="color:#b5cea8;">0</span><span class="punctuation">);</span><span class="comment" style="color:#57a64a;">//行數</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">colLength</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">GetLength</span><span class="punctuation">(</span><span class="number" style="color:#b5cea8;">1</span><span class="punctuation">);</span><span class="comment" style="color:#57a64a;">//列數</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">colLength</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;</span>&nbsp;<span class="number" style="color:#b5cea8;">2</span><span class="punctuation">)</span>&nbsp;<span class="keyword" style="color:#569cd6;">throw</span>&nbsp;<span class="keyword" style="color:#569cd6;">new</span>&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">IndexOutOfRangeException</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">&quot;arr.GetLength(1)的值必須大於等於2&quot;</span><span class="punctuation">);</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">result</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="keyword" style="color:#569cd6;">new</span>&nbsp;<span class="keyword" style="color:#569cd6;">int</span><span class="operator" style="color:#b4b4b4;">?</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">colLength</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">];</span><br/><span class="preprocessor keyword" style="color:#9b9b9b;">#if</span>&nbsp;<span class="identifier">DEBUG</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">&quot;解一元屢次方程:&quot;</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - method name - (TRANSIENT)">PrintArr</span><span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">);</span><br/><span class="preprocessor keyword" style="color:#9b9b9b;">#endif</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">mainCol</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colLength</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">)</span>&nbsp;<span class="comment" style="color:#57a64a;">//按照列,一列一列的消元</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">mainRow</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">;</span>&nbsp;<span class="comment" style="color:#57a64a;">//主元行=主元列</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">row</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainRow</span>&nbsp;<span class="operator" style="color:#b4b4b4;">+</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">row</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">rowLength</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">row</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">)</span>&nbsp;<span class="comment" style="color:#57a64a;">//&nbsp;從主元的下一行開始&nbsp;行循環</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">row</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&gt;=</span>&nbsp;<span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">colLength</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">))</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">break</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment" style="color:#57a64a;">/*<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;n1*X&nbsp;+&nbsp;n2*Y&nbsp;=&nbsp;a&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m1*X&nbsp;+&nbsp;m2*Y&nbsp;=&nbsp;b&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&gt;&nbsp;&nbsp;n1*m1*X&nbsp;+&nbsp;n2*m1Y&nbsp;=&nbsp;a*m1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&gt;&nbsp;&nbsp;m1*n1*X&nbsp;+&nbsp;m2*n1*Y&nbsp;=&nbsp;b*n1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment" style="color:#57a64a;">//若是主元參數爲0(&nbsp;找出此列不爲0的行)&nbsp;運用行相加&nbsp;&nbsp;變換0參數</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">mainRow</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">rowi</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainRow</span>&nbsp;<span class="operator" style="color:#b4b4b4;">+</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">rowi</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">rowLength</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">rowi</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">rowi</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">!=</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">colj</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colj</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colLength</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colj</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">mainRow</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colj</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">+=</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">rowi</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colj</span><span class="punctuation">];</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">break</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">continue</span><span class="punctuation">;</span>&nbsp;<span class="comment" style="color:#57a64a;">//當前行&nbsp;此列已是0&nbsp;繼續消元下一行</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">m</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - method name - (TRANSIENT)">GetMinCommonMultiple</span><span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">],</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">]);</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">factorMain</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">m</span>&nbsp;<span class="operator" style="color:#b4b4b4;">/</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">];</span><span class="comment" style="color:#57a64a;">//主列的因子&nbsp;&nbsp;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">factor</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">m</span>&nbsp;<span class="operator" style="color:#b4b4b4;">/</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">];</span>&nbsp;<span class="comment" style="color:#57a64a;">//待消元列因子</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">colk</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colk</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colLength</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colk</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colk</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">mainCol</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colk</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">*</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">factorMain</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colk</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">*</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">factor</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/><span class="preprocessor keyword" style="color:#9b9b9b;">#if</span>&nbsp;<span class="identifier">DEBUG</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">rowLength</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&gt;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">mainCol</span>&nbsp;<span class="operator" style="color:#b4b4b4;">+</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - method name - (TRANSIENT)">PrintArr</span><span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">);</span><br/><span class="preprocessor keyword" style="color:#9b9b9b;">#endif</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment" style="color:#57a64a;">//回代過程&nbsp;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment" style="color:#57a64a;">//回代行&nbsp;判斷&nbsp;行數是否大於列數減-1&nbsp;&nbsp;取到能夠計算結果的回代行</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">backRow</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">rowLength</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&gt;</span>&nbsp;<span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">colLength</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">)</span>&nbsp;<span class="operator" style="color:#b4b4b4;">?</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colLength</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span>&nbsp;<span class="operator" style="color:#b4b4b4;">:</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">rowLength</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">backRowIndex</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">backRow</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">;</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment" style="color:#57a64a;">//回代行的結果值</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">backValue</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">backRowIndex</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colLength</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">];</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment" style="color:#57a64a;">//判斷消解行&nbsp;有多少個變元&nbsp;,存儲&nbsp;變元的&nbsp;索引</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">listColIndex</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="keyword" style="color:#569cd6;">new</span>&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">List</span><span class="punctuation">&lt;</span><span class="keyword" style="color:#569cd6;">int</span><span class="punctuation">&gt;();</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">col</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">col</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colLength</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">col</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">backRowIndex</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">col</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">!=</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - local name - (TRANSIENT)">listColIndex</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">Add</span><span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">col</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">listColIndex</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - property name - (TRANSIENT)">Count</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">return</span>&nbsp;<span class="keyword" style="color:#569cd6;">null</span><span class="punctuation">;</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment" style="color:#57a64a;">//根據須要求解的個數&nbsp;解不定方程處理</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">listColIndex</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - property name - (TRANSIENT)">Count</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&gt;</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">resoveArr</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">listColIndex</span><span class="operator" style="color:#b4b4b4;">.</span><span class="extension method name - identifier - (TRANSIENT)">Select</span><span class="punctuation">(</span><span class="parameter name">x</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=&gt;</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">backRowIndex</span><span class="punctuation">,</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">x</span><span class="punctuation">])</span><span class="operator" style="color:#b4b4b4;">.</span><span class="extension method name - identifier - (TRANSIENT)">ToArray</span><span class="punctuation">();</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">resoveResultArr</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="keyword" style="color:#569cd6;">new</span>&nbsp;<span class="keyword" style="color:#569cd6;">int</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">listColIndex</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - property name - (TRANSIENT)">Count</span><span class="punctuation">];</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">count</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">flag</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - method name - (TRANSIENT)">ResoveIndefiniteEquation</span><span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">resoveArr</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">backValue</span><span class="punctuation">,</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">,</span>&nbsp;<span class="keyword" style="color:#569cd6;">ref</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">resoveResultArr</span><span class="punctuation">,</span>&nbsp;<span class="keyword" style="color:#569cd6;">ref</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">count</span><span class="punctuation">);</span><br/><span class="preprocessor keyword" style="color:#9b9b9b;">#if</span>&nbsp;<span class="identifier">DEBUG</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">();</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">&quot;--解不定方程&quot;</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">sb</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="keyword" style="color:#569cd6;">new</span>&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">StringBuilder</span><span class="punctuation">();</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colLength</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - local name - (TRANSIENT)">sb</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">Append</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">&quot;********&quot;</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">sb</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">ToString</span><span class="punctuation">());</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">$&quot;方程:&nbsp;</span><span class="punctuation">{</span><span class="keyword" style="color:#569cd6;">string</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">Join</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">&quot;,\t&quot;</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">resoveArr</span><span class="punctuation">)}</span><span class="string" style="color:#d69d85;">&nbsp;=&nbsp;</span><span class="punctuation">{</span><span class="identifier - local name - (TRANSIENT)">backValue</span><span class="punctuation">}</span><span class="string" style="color:#d69d85;">&quot;</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">$&quot;結果:&nbsp;</span><span class="punctuation">{</span><span class="keyword" style="color:#569cd6;">string</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">Join</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">&quot;,\t&quot;</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">resoveResultArr</span><span class="punctuation">)}</span><span class="string" style="color:#d69d85;">&quot;</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">$&quot;計算:&nbsp;</span><span class="punctuation">{</span><span class="keyword" style="color:#569cd6;">string</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">Join</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">&quot;,\t&quot;</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">resoveResultArr</span><span class="operator" style="color:#b4b4b4;">.</span><span class="extension method name - identifier - (TRANSIENT)">Select</span><span class="punctuation">((</span><span class="parameter name">x</span><span class="punctuation">,</span>&nbsp;<span class="parameter name">index</span><span class="punctuation">)</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=&gt;</span>&nbsp;<span class="string" style="color:#d69d85;">$&quot;</span><span class="punctuation">{</span><span class="identifier - parameter name - (TRANSIENT)">x</span>&nbsp;<span class="operator" style="color:#b4b4b4;">*</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">resoveArr</span><span class="punctuation">[</span><span class="identifier - parameter name - (TRANSIENT)">index</span><span class="punctuation">]}</span><span class="string" style="color:#d69d85;">&quot;</span><span class="punctuation">))}</span><span class="string" style="color:#d69d85;">&quot;</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">$&quot;遞歸次數:&nbsp;</span><span class="punctuation">{</span><span class="identifier - local name - (TRANSIENT)">count</span><span class="punctuation">}</span><span class="string" style="color:#d69d85;">&quot;</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">sb</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">ToString</span><span class="punctuation">());</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">();</span><br/><span class="preprocessor keyword" style="color:#9b9b9b;">#endif</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="operator" style="color:#b4b4b4;">!</span><span class="identifier - local name - (TRANSIENT)">flag</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">return</span>&nbsp;<span class="keyword" style="color:#569cd6;">null</span><span class="punctuation">;</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">resoveResultArr</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - property name - (TRANSIENT)">Length</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - local name - (TRANSIENT)">result</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">listColIndex</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">i</span><span class="punctuation">]]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">resoveResultArr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">i</span><span class="punctuation">];</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">listColIndex</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - property name - (TRANSIENT)">Count</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">backValue</span>&nbsp;<span class="operator" style="color:#b4b4b4;">%</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">backRowIndex</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">listColIndex</span><span class="punctuation">[</span><span class="number" style="color:#b5cea8;">0</span><span class="punctuation">]]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - local name - (TRANSIENT)">result</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">listColIndex</span><span class="punctuation">[</span><span class="number" style="color:#b5cea8;">0</span><span class="punctuation">]]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">backValue</span>&nbsp;<span class="operator" style="color:#b4b4b4;">/</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">backRowIndex</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">listColIndex</span><span class="punctuation">[</span><span class="number" style="color:#b5cea8;">0</span><span class="punctuation">]];</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">else</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/><span class="preprocessor keyword" style="color:#9b9b9b;">#if</span>&nbsp;<span class="identifier">DEBUG</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">number</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">backValue</span>&nbsp;<span class="operator" style="color:#b4b4b4;">*</span>&nbsp;<span class="number" style="color:#b5cea8;">1.0</span>&nbsp;<span class="operator" style="color:#b4b4b4;">/</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">backRowIndex</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">listColIndex</span><span class="punctuation">[</span><span class="number" style="color:#b5cea8;">0</span><span class="punctuation">]];</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">$&quot;第</span><span class="punctuation">{</span><span class="identifier - local name - (TRANSIENT)">backRow</span><span class="punctuation">}</span><span class="string" style="color:#d69d85;">行&nbsp;</span><span class="punctuation">{</span><span class="identifier - local name - (TRANSIENT)">backValue</span><span class="punctuation">}</span><span class="string" style="color:#d69d85;">/</span><span class="punctuation">{</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">backRowIndex</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">listColIndex</span><span class="punctuation">[</span><span class="number" style="color:#b5cea8;">0</span><span class="punctuation">]]}</span><span class="string" style="color:#d69d85;">&nbsp;=&nbsp;</span><span class="punctuation">{</span><span class="identifier - local name - (TRANSIENT)">number</span><span class="punctuation">}</span><span class="string" style="color:#d69d85;">,&nbsp;不能被被整除計算失敗&quot;</span><span class="punctuation">);</span><br/><span class="preprocessor keyword" style="color:#9b9b9b;">#endif</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">return</span>&nbsp;<span class="keyword" style="color:#569cd6;">null</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/> <br/> <br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">row</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">backRowIndex</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">row</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&gt;=</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">row</span><span class="operator" style="color:#b4b4b4;">--</span><span class="punctuation">)</span>&nbsp;<span class="comment" style="color:#57a64a;">//從倒數第二行開始往前迭代</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">continue</span><span class="punctuation">;</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">addResult</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">currlist</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="keyword" style="color:#569cd6;">new</span>&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">List</span><span class="punctuation">&lt;</span><span class="keyword" style="color:#569cd6;">int</span><span class="punctuation">&gt;();</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">j</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">j</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colLength</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="number" style="color:#b5cea8;">2</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">j</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">)</span><span class="comment" style="color:#57a64a;">//j=2&nbsp;&nbsp;&nbsp;j&nbsp;最大值爲2,每行未知數可能不止一個,故須要遍歷已知的未知數並代入</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="operator" style="color:#b4b4b4;">!</span><span class="identifier - local name - (TRANSIENT)">result</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">j</span>&nbsp;<span class="operator" style="color:#b4b4b4;">+</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">]</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - property name - (TRANSIENT)">HasValue</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&amp;&amp;</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">j</span>&nbsp;<span class="operator" style="color:#b4b4b4;">+</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">!=</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - local name - (TRANSIENT)">currlist</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">Add</span><span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">j</span>&nbsp;<span class="operator" style="color:#b4b4b4;">+</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">);</span><span class="comment" style="color:#57a64a;">//把沒有計算出結果的列的索引存入</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">else</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - local name - (TRANSIENT)">addResult</span>&nbsp;<span class="operator" style="color:#b4b4b4;">+=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">result</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">j</span>&nbsp;<span class="operator" style="color:#b4b4b4;">+</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">]</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">GetValueOrDefault</span><span class="punctuation">()</span>&nbsp;<span class="operator" style="color:#b4b4b4;">*</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">j</span>&nbsp;<span class="operator" style="color:#b4b4b4;">+</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">];</span><span class="comment" style="color:#57a64a;">//k表明計算的行,j+1表明的列,係數與解要對應,故都爲&nbsp;j+1</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">calculateValue</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colLength</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">addResult</span><span class="punctuation">;</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment" style="color:#57a64a;">//發現沒有計算出結果的列&nbsp;解不定方程</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">currlist</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - property name - (TRANSIENT)">Count</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&gt;</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - local name - (TRANSIENT)">currlist</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">Add</span><span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">resoveArr</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">currlist</span><span class="operator" style="color:#b4b4b4;">.</span><span class="extension method name - identifier - (TRANSIENT)">Select</span><span class="punctuation">(</span><span class="parameter name">x</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=&gt;</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">,</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">x</span><span class="punctuation">])</span><span class="operator" style="color:#b4b4b4;">.</span><span class="extension method name - identifier - (TRANSIENT)">ToArray</span><span class="punctuation">();</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">resoveResultArr</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="keyword" style="color:#569cd6;">new</span>&nbsp;<span class="keyword" style="color:#569cd6;">int</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">currlist</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - property name - (TRANSIENT)">Count</span><span class="punctuation">];</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">count</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">flag</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - method name - (TRANSIENT)">ResoveIndefiniteEquation</span><span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">resoveArr</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">calculateValue</span><span class="punctuation">,</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">,</span>&nbsp;<span class="keyword" style="color:#569cd6;">ref</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">resoveResultArr</span><span class="punctuation">,</span>&nbsp;<span class="keyword" style="color:#569cd6;">ref</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">count</span><span class="punctuation">);</span><br/><span class="preprocessor keyword" style="color:#9b9b9b;">#if</span>&nbsp;<span class="identifier">DEBUG</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">();</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">$&quot;----發現第</span><span class="punctuation">{</span><span class="identifier - local name - (TRANSIENT)">row</span>&nbsp;<span class="operator" style="color:#b4b4b4;">+</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">}</span><span class="string" style="color:#d69d85;">行&nbsp;第(</span><span class="punctuation">{</span><span class="keyword" style="color:#569cd6;">string</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">Join</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">&quot;,&quot;</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">currlist</span><span class="punctuation">)}</span><span class="string" style="color:#d69d85;">)列&nbsp;沒有計算出結果,須要解不定方程&quot;</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">sb</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="keyword" style="color:#569cd6;">new</span>&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">StringBuilder</span><span class="punctuation">();</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colLength</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - local name - (TRANSIENT)">sb</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">Append</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">&quot;********&quot;</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">sb</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">ToString</span><span class="punctuation">());</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">$&quot;方程:&nbsp;</span><span class="punctuation">{</span><span class="keyword" style="color:#569cd6;">string</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">Join</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">&quot;,\t&quot;</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">resoveArr</span><span class="punctuation">)}</span><span class="string" style="color:#d69d85;">&nbsp;=&nbsp;</span><span class="punctuation">{</span><span class="identifier - local name - (TRANSIENT)">calculateValue</span><span class="punctuation">}</span><span class="string" style="color:#d69d85;">&quot;</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">$&quot;結果:&nbsp;</span><span class="punctuation">{</span><span class="keyword" style="color:#569cd6;">string</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">Join</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">&quot;,\t&quot;</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">resoveResultArr</span><span class="punctuation">)}</span><span class="string" style="color:#d69d85;">&quot;</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">$&quot;計算:&nbsp;</span><span class="punctuation">{</span><span class="keyword" style="color:#569cd6;">string</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">Join</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">&quot;,\t&quot;</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">resoveResultArr</span><span class="operator" style="color:#b4b4b4;">.</span><span class="extension method name - identifier - (TRANSIENT)">Select</span><span class="punctuation">((</span><span class="parameter name">x</span><span class="punctuation">,</span>&nbsp;<span class="parameter name">index</span><span class="punctuation">)</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=&gt;</span>&nbsp;<span class="string" style="color:#d69d85;">$&quot;</span><span class="punctuation">{</span><span class="identifier - parameter name - (TRANSIENT)">x</span>&nbsp;<span class="operator" style="color:#b4b4b4;">*</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">resoveArr</span><span class="punctuation">[</span><span class="identifier - parameter name - (TRANSIENT)">index</span><span class="punctuation">]}</span><span class="string" style="color:#d69d85;">&quot;</span><span class="punctuation">))}</span><span class="string" style="color:#d69d85;">&quot;</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">$&quot;遞歸次數:&nbsp;</span><span class="punctuation">{</span><span class="identifier - local name - (TRANSIENT)">count</span><span class="punctuation">}</span><span class="string" style="color:#d69d85;">&quot;</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">sb</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">ToString</span><span class="punctuation">());</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">();</span><br/><span class="preprocessor keyword" style="color:#9b9b9b;">#endif</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="operator" style="color:#b4b4b4;">!</span><span class="identifier - local name - (TRANSIENT)">flag</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">return</span>&nbsp;<span class="keyword" style="color:#569cd6;">null</span><span class="punctuation">;</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">resoveResultArr</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - property name - (TRANSIENT)">Length</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - local name - (TRANSIENT)">result</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">currlist</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">i</span><span class="punctuation">]]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">resoveResultArr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">i</span><span class="punctuation">];</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">else</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">calculateValue</span>&nbsp;<span class="operator" style="color:#b4b4b4;">%</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - local name - (TRANSIENT)">result</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">calculateValue</span>&nbsp;<span class="operator" style="color:#b4b4b4;">/</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">];</span><span class="comment" style="color:#57a64a;">//本行的未知數用本行最右邊數-本行已知未知數代入係數之差&nbsp;再除以本未知數係數</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">else</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/><span class="preprocessor keyword" style="color:#9b9b9b;">#if</span>&nbsp;<span class="identifier">DEBUG</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">number</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">calculateValue</span>&nbsp;<span class="operator" style="color:#b4b4b4;">*</span>&nbsp;<span class="number" style="color:#b5cea8;">1.0</span>&nbsp;<span class="operator" style="color:#b4b4b4;">/</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">];</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">$&quot;第</span><span class="punctuation">{</span><span class="identifier - local name - (TRANSIENT)">row</span>&nbsp;<span class="operator" style="color:#b4b4b4;">+</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">}</span><span class="string" style="color:#d69d85;">行&nbsp;</span><span class="punctuation">{</span><span class="identifier - local name - (TRANSIENT)">calculateValue</span><span class="punctuation">}</span><span class="string" style="color:#d69d85;">/</span><span class="punctuation">{</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">row</span><span class="punctuation">]}</span><span class="string" style="color:#d69d85;">&nbsp;=&nbsp;</span><span class="punctuation">{</span><span class="identifier - local name - (TRANSIENT)">number</span><span class="punctuation">}</span><span class="string" style="color:#d69d85;">,&nbsp;不能被被整除計算失敗&quot;</span><span class="punctuation">);</span><br/><span class="preprocessor keyword" style="color:#9b9b9b;">#endif</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">return</span>&nbsp;<span class="keyword" style="color:#569cd6;">null</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/> <br/><span class="preprocessor keyword" style="color:#9b9b9b;">#if</span>&nbsp;<span class="identifier">DEBUG</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">&quot;----------結果------------&quot;</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">Write</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">$&quot;結果:&nbsp;</span><span class="punctuation">{</span><span class="keyword" style="color:#569cd6;">string</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">Join</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">&quot;,&quot;</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">result</span><span class="punctuation">)}</span><span class="string" style="color:#d69d85;">&quot;</span><span class="punctuation">);</span><br/><span class="preprocessor keyword" style="color:#9b9b9b;">#endif</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">return</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">result</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&lt;</span><span class="xml doc comment - name" style="color:#608b4e;">summary</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;解不定方程</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&lt;/</span><span class="xml doc comment - name" style="color:#608b4e;">summary</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">public</span>&nbsp;<span class="keyword" style="color:#569cd6;">static</span>&nbsp;<span class="keyword" style="color:#569cd6;">bool</span>&nbsp;<span class="method name">ResoveIndefiniteEquation</span><span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span><span class="punctuation">[]</span>&nbsp;<span class="parameter name">arr</span><span class="punctuation">,</span>&nbsp;<span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="parameter name">value</span><span class="punctuation">,</span>&nbsp;<span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="parameter name">startIndex</span><span class="punctuation">,</span>&nbsp;<span class="keyword" style="color:#569cd6;">ref</span>&nbsp;<span class="keyword" style="color:#569cd6;">int</span><span class="punctuation">[]</span>&nbsp;<span class="parameter name">result</span><span class="punctuation">,</span>&nbsp;<span class="keyword" style="color:#569cd6;">ref</span>&nbsp;<span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="parameter name">count</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - parameter name - (TRANSIENT)">count</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">;</span><span class="comment" style="color:#57a64a;">//遞歸計數,防止無限遞歸</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">arr</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="keyword" style="color:#569cd6;">null</span>&nbsp;<span class="operator" style="color:#b4b4b4;">||</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - property name - (TRANSIENT)">Length</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">return</span>&nbsp;<span class="keyword" style="color:#569cd6;">false</span><span class="punctuation">;</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - property name - (TRANSIENT)">Length</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">reValue</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">value</span>&nbsp;<span class="operator" style="color:#b4b4b4;">/</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="number" style="color:#b5cea8;">0</span><span class="punctuation">];</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">value</span>&nbsp;<span class="operator" style="color:#b4b4b4;">%</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="number" style="color:#b5cea8;">0</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&amp;&amp;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">reValue</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&gt;=</span>&nbsp;<span class="constant name - identifier - (TRANSIENT)">MinResove</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&amp;&amp;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">reValue</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;=</span>&nbsp;<span class="constant name - identifier - (TRANSIENT)">MaxResove</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - parameter name - (TRANSIENT)">result</span><span class="punctuation">[</span><span class="identifier - parameter name - (TRANSIENT)">startIndex</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">reValue</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">return</span>&nbsp;<span class="keyword" style="color:#569cd6;">true</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">return</span>&nbsp;<span class="keyword" style="color:#569cd6;">false</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment" style="color:#57a64a;">//獲取第二部分元的最大公約數</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">commonDivisor</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="number" style="color:#b5cea8;">1</span><span class="punctuation">];</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;</span>&nbsp;<span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - property name - (TRANSIENT)">Length</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">);</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - local name - (TRANSIENT)">commonDivisor</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - method name - (TRANSIENT)">GetCommonDivisor</span><span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">commonDivisor</span><span class="punctuation">,</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">+</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">]);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="constant name - identifier - (TRANSIENT)">MinResove</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;=</span>&nbsp;<span class="constant name - identifier - (TRANSIENT)">MaxResove</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">currValue</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">value</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">*</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="number" style="color:#b5cea8;">0</span><span class="punctuation">];</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">currValue</span>&nbsp;<span class="operator" style="color:#b4b4b4;">%</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">commonDivisor</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">newArr</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="keyword" style="color:#569cd6;">new</span>&nbsp;<span class="keyword" style="color:#569cd6;">int</span><span class="punctuation">[</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - property name - (TRANSIENT)">Length</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">];</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Array</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">Copy</span><span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">,</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">newArr</span><span class="punctuation">,</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">,</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - property name - (TRANSIENT)">Length</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">);</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - parameter name - (TRANSIENT)">result</span><span class="punctuation">[</span><span class="identifier - parameter name - (TRANSIENT)">startIndex</span><span class="punctuation">]</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">currArr</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - method name - (TRANSIENT)">ResoveIndefiniteEquation</span><span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">newArr</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">currValue</span><span class="punctuation">,</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">startIndex</span>&nbsp;<span class="operator" style="color:#b4b4b4;">+</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">,</span>&nbsp;<span class="keyword" style="color:#569cd6;">ref</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">result</span><span class="punctuation">,</span>&nbsp;<span class="keyword" style="color:#569cd6;">ref</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">count</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">currArr</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">return</span>&nbsp;<span class="keyword" style="color:#569cd6;">true</span><span class="punctuation">;</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">count</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&gt;</span>&nbsp;<span class="number" style="color:#b5cea8;">1000000</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">&quot;遞歸太深沒法求解&quot;</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">return</span>&nbsp;<span class="keyword" style="color:#569cd6;">false</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">return</span>&nbsp;<span class="keyword" style="color:#569cd6;">false</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">private</span>&nbsp;<span class="keyword" style="color:#569cd6;">static</span>&nbsp;<span class="keyword" style="color:#569cd6;">void</span>&nbsp;<span class="method name">PrintArr</span><span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span><span class="punctuation">[,]</span>&nbsp;<span class="parameter name">arr</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">rowLength</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">GetLength</span><span class="punctuation">(</span><span class="number" style="color:#b5cea8;">0</span><span class="punctuation">);</span><span class="comment" style="color:#57a64a;">//行數</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">colLength</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">GetLength</span><span class="punctuation">(</span><span class="number" style="color:#b5cea8;">1</span><span class="punctuation">);</span><span class="comment" style="color:#57a64a;">//列數</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">sb</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="keyword" style="color:#569cd6;">new</span>&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">StringBuilder</span><span class="punctuation">();</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colLength</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - local name - (TRANSIENT)">sb</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">Append</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">&quot;--------&quot;</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">sb</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">ToString</span><span class="punctuation">());</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">rowLength</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">i</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">for</span>&nbsp;<span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="local name">j</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">j</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">colLength</span><span class="punctuation">;</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">j</span><span class="operator" style="color:#b4b4b4;">++</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">Write</span><span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">arr</span><span class="punctuation">[</span><span class="identifier - local name - (TRANSIENT)">i</span><span class="punctuation">,</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">j</span><span class="punctuation">]);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">str</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">j</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">colLength</span>&nbsp;<span class="operator" style="color:#b4b4b4;">-</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">)</span>&nbsp;<span class="operator" style="color:#b4b4b4;">?</span>&nbsp;<span class="string" style="color:#d69d85;">&quot;&quot;</span>&nbsp;<span class="operator" style="color:#b4b4b4;">:</span>&nbsp;<span class="string" style="color:#d69d85;">&quot;,&quot;</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">Write</span><span class="punctuation">(</span><span class="string" style="color:#d69d85;">$&quot;&nbsp;</span><span class="punctuation">{</span><span class="identifier - local name - (TRANSIENT)">str</span><span class="punctuation">}</span><span class="string" style="color:#d69d85;">\t&nbsp;&quot;</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">WriteLine</span><span class="punctuation">();</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&lt;</span><span class="xml doc comment - name" style="color:#608b4e;">summary</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;求最大公約數</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&lt;/</span><span class="xml doc comment - name" style="color:#608b4e;">summary</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&lt;</span><span class="xml doc comment - name" style="color:#608b4e;">param</span><span class="xml doc comment - attribute name" style="color:#c8c8c8;">&nbsp;name</span><span class="xml doc comment - delimiter" style="color:#608b4e;">=</span><span class="xml doc comment - attribute quotes" style="color:#c8c8c8;">&quot;</span><span class="identifier - parameter name - (TRANSIENT)">a</span><span class="xml doc comment - attribute quotes" style="color:#c8c8c8;">&quot;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;&lt;/</span><span class="xml doc comment - name" style="color:#608b4e;">param</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&lt;</span><span class="xml doc comment - name" style="color:#608b4e;">param</span><span class="xml doc comment - attribute name" style="color:#c8c8c8;">&nbsp;name</span><span class="xml doc comment - delimiter" style="color:#608b4e;">=</span><span class="xml doc comment - attribute quotes" style="color:#c8c8c8;">&quot;</span><span class="identifier - parameter name - (TRANSIENT)">b</span><span class="xml doc comment - attribute quotes" style="color:#c8c8c8;">&quot;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;&lt;/</span><span class="xml doc comment - name" style="color:#608b4e;">param</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&lt;</span><span class="xml doc comment - name" style="color:#608b4e;">returns</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;&lt;/</span><span class="xml doc comment - name" style="color:#608b4e;">returns</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">public</span>&nbsp;<span class="keyword" style="color:#569cd6;">static</span>&nbsp;<span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="method name">GetCommonDivisor</span><span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="parameter name">a</span><span class="punctuation">,</span>&nbsp;<span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="parameter name">b</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">a</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span>&nbsp;<span class="operator" style="color:#b4b4b4;">||</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">b</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">)</span>&nbsp;<span class="keyword" style="color:#569cd6;">return</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Math</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">Abs</span><span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">a</span><span class="punctuation">)</span>&nbsp;<span class="operator" style="color:#b4b4b4;">&lt;</span>&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Math</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">Abs</span><span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">b</span><span class="punctuation">))</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">temp</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">a</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - parameter name - (TRANSIENT)">a</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">b</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="identifier - parameter name - (TRANSIENT)">b</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">temp</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">return</span>&nbsp;<span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">a</span>&nbsp;<span class="operator" style="color:#b4b4b4;">%</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">b</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">)</span>&nbsp;<span class="operator" style="color:#b4b4b4;">?</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">b</span>&nbsp;<span class="operator" style="color:#b4b4b4;">:</span>&nbsp;<span class="identifier - method name - (TRANSIENT)">GetCommonDivisor</span><span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">a</span>&nbsp;<span class="operator" style="color:#b4b4b4;">%</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">b</span><span class="punctuation">,</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">b</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&lt;</span><span class="xml doc comment - name" style="color:#608b4e;">summary</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;求最小公倍數&nbsp;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&lt;/</span><span class="xml doc comment - name" style="color:#608b4e;">summary</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&lt;</span><span class="xml doc comment - name" style="color:#608b4e;">param</span><span class="xml doc comment - attribute name" style="color:#c8c8c8;">&nbsp;name</span><span class="xml doc comment - delimiter" style="color:#608b4e;">=</span><span class="xml doc comment - attribute quotes" style="color:#c8c8c8;">&quot;</span><span class="identifier - parameter name - (TRANSIENT)">a</span><span class="xml doc comment - attribute quotes" style="color:#c8c8c8;">&quot;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;&lt;/</span><span class="xml doc comment - name" style="color:#608b4e;">param</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&lt;</span><span class="xml doc comment - name" style="color:#608b4e;">param</span><span class="xml doc comment - attribute name" style="color:#c8c8c8;">&nbsp;name</span><span class="xml doc comment - delimiter" style="color:#608b4e;">=</span><span class="xml doc comment - attribute quotes" style="color:#c8c8c8;">&quot;</span><span class="identifier - parameter name - (TRANSIENT)">b</span><span class="xml doc comment - attribute quotes" style="color:#c8c8c8;">&quot;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;&lt;/</span><span class="xml doc comment - name" style="color:#608b4e;">param</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="xml doc comment - delimiter" style="color:#608b4e;">///</span><span class="xml doc comment - text" style="color:#608b4e;">&nbsp;</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&lt;</span><span class="xml doc comment - name" style="color:#608b4e;">returns</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;&lt;/</span><span class="xml doc comment - name" style="color:#608b4e;">returns</span><span class="xml doc comment - delimiter" style="color:#608b4e;">&gt;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">public</span>&nbsp;<span class="keyword" style="color:#569cd6;">static</span>&nbsp;<span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="method name">GetMinCommonMultiple</span><span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="parameter name">a</span><span class="punctuation">,</span>&nbsp;<span class="keyword" style="color:#569cd6;">int</span>&nbsp;<span class="parameter name">b</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">commonDivisor</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="identifier - method name - (TRANSIENT)">GetCommonDivisor</span><span class="punctuation">(</span><span class="identifier - parameter name - (TRANSIENT)">a</span><span class="punctuation">,</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">b</span><span class="punctuation">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">if</span>&nbsp;<span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">commonDivisor</span>&nbsp;<span class="operator" style="color:#b4b4b4;">==</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">return</span>&nbsp;<span class="number" style="color:#b5cea8;">0</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">return</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">a</span>&nbsp;<span class="operator" style="color:#b4b4b4;">*</span>&nbsp;<span class="identifier - parameter name - (TRANSIENT)">b</span>&nbsp;<span class="operator" style="color:#b4b4b4;">/</span>&nbsp;<span class="identifier - local name - (TRANSIENT)">commonDivisor</span><span class="punctuation">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span></div>ui

4. 運行結果

<div style="font-family: Arial; font-size: 13; color: gainsboro; background: #1e1e1e;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">static</span>&nbsp;<span class="keyword" style="color:#569cd6;">void</span>&nbsp;<span class="method name">Main</span><span class="punctuation">(</span><span class="keyword" style="color:#569cd6;">string</span><span class="punctuation">[]</span>&nbsp;<span class="parameter name">args</span><span class="punctuation">)</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="color:#569cd6;">var</span>&nbsp;<span class="local name">arr</span>&nbsp;<span class="operator" style="color:#b4b4b4;">=</span>&nbsp;<span class="keyword" style="color:#569cd6;">new</span>&nbsp;<span class="keyword" style="color:#569cd6;">int</span><span class="punctuation">[,]</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span>&nbsp;<span class="number" style="color:#b5cea8;">2</span><span class="punctuation">,</span>&nbsp;<span class="number" style="color:#b5cea8;">3</span><span class="punctuation">,</span>&nbsp;<span class="number" style="color:#b5cea8;">4</span><span class="punctuation">,</span>&nbsp;<span class="number" style="color:#b5cea8;">3</span><span class="punctuation">,</span>&nbsp;<span class="number" style="color:#b5cea8;">21</span>&nbsp;<span class="punctuation">},</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span>&nbsp;<span class="number" style="color:#b5cea8;">3</span><span class="punctuation">,</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">,</span>&nbsp;<span class="number" style="color:#b5cea8;">6</span><span class="punctuation">,</span>&nbsp;<span class="number" style="color:#b5cea8;">2</span><span class="punctuation">,</span>&nbsp;<span class="number" style="color:#b5cea8;">17</span>&nbsp;<span class="punctuation">},</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">{</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">,</span>&nbsp;<span class="number" style="color:#b5cea8;">3</span><span class="punctuation">,</span>&nbsp;<span class="number" style="color:#b5cea8;">2</span><span class="punctuation">,</span>&nbsp;<span class="number" style="color:#b5cea8;">1</span><span class="punctuation">,</span>&nbsp;<span class="number" style="color:#b5cea8;">12</span><span class="punctuation">},</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">};</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">GaussHelper</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">ResoveGauss</span><span class="punctuation">(</span><span class="identifier - local name - (TRANSIENT)">arr</span><span class="punctuation">);</span><br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="class name - identifier - (TRANSIENT)" style="color:#4ec9b0;">Console</span><span class="operator" style="color:#b4b4b4;">.</span><span class="identifier - method name - (TRANSIENT)">ReadKey</span><span class="punctuation">();</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="punctuation">}</span></div>spa

原文出處:https://www.cnblogs.com/castyuan/p/10251885.htmlxml

相關文章
相關標籤/搜索