算法/查找最大值/vb 脚本方法 2
外观
<script type="text/vbscript">
function findNoOfElement(i_intAry) Dim o_intCount o_intCount = 0 for each objEle in i_intAry o_intCount = o_intCount + 1 next findNoOfElement = o_intCount end function function findMax(i_intAry,i_intSize) Dim oRes if ( i_intSize <= 3 ) then if i_intAry(0) > i_intAry(1) then oRes = i_intAry(0) else oRes = i_intAry(1) end if else Dim yy yy = i_intSize /2 Dim p_intAryA() Dim p_intAryB() ReDim p_intAryA(yy) ReDim p_intAryB(yy) Dim p_intI Dim p_intJ for p_intI = 0 to (yy - 1) step 1 p_intAryA(p_intI) = i_intAry(p_intI) next Dim p_intK for p_intJ = yy to (i_intSize - 1) step 1 p_intAryB(p_intK) = i_intAry(p_intJ) next Dim o_intM Dim o_intN o_intM = findMax(p_intAryA,findNoOfElement(p_intAryA)) o_intN = findMax(p_intAryB,findNoOfElement(p_intAryB)) if ( o_intM > o_intN ) then oRes = o_intM else oRes = o_intN end if end if findMax = oRes end function Dim cc(3) cc(0) = 33 cc(1) = 6 cc(2) = 7 cc(3) = 11 document.write("Max is " & findMax(cc,findNoOfElement(cc)) ) </script>