Jump to content

Algorithms/Find maximum/vb script method 4

From Wikibooks, open books for an open world

<script type="text/vbscript">

    function findMin(aa)
       Dim o_intMin
       o_intMin = aa(0)
       for each p_intJ in aa
          if p_intJ < o_intMin then
              o_intMin = p_intJ
          end if
       next
       findMin = o_intMin
    end function
    function findMax(aa)
       Dim p_intI 
       p_intI = 0
       for each x in aa
          aa(p_intI) = x * -1
          p_intI = p_intI + 1
       next
       findMax = findMin(aa) * -1
    end function    
    Dim cc(4)
    cc(0) = 1
    cc(1) = 2
    cc(2) = 6
    cc(3) = 4
    cc(4) = 1
    document.write(findMax(cc))
 </script>