Algorithms/Find maximum/jscript 2
(Redirected from Find maximum/jscript 2)
<script language="jscript">
function findMax(i_intaryTab) { if ( i_intaryTab.length == 2 ) { if ( i_intaryTab[0] > i_intaryTab[1] ) return i_intaryTab[0]; else return i_intaryTab[1]; } // end if if ( i_intaryTab.length == 1 ) return i_intaryTb[0]; var yy = i_intaryTab.length / 2; var p_intaryA = new Array(yy); var p_intaryB = new Array(yy); for (var p_intI = 0; p_intI < yy ; p_intI += 1) p_intaryA[p_intI] = i_intaryTab[p_intI]; var p_intK = 0; for (var p_intJ = yy; p_intJ < i_intaryTab.length; p_intJ +=1,p_intK += 1) p_intaryB[p_intK] = i_intaryTab[p_intJ]; var o_intM = findMax(p_intaryA); var o_intN = findMax(p_intaryB); if ( o_intM > o_intN ) return o_intM; else return o_intN; } // end method var cc = new Array(1,2,3,4); document.write(findMax(cc)); </script>