Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

java, index of maximum element in array

Name: Anonymous 2009-01-26 12:02

public static int maximum(double[] a){
  double max = a[0];
  int position = 0;
  for (int i = 1; i < a.length; i++) {
    if (a[i] > max) {
      max = a[i];
      position = i;
    }
  }
  return position;
}

//DONE.

Name: Anonymous 2009-01-26 12:47

PHP, index of maxium element in ary

$maximum = -1;

function maxxiumElementsindex($length, $array){
global $maximum; //so u can acses this outside the functon
$valu = false;
foreach($array as $k => $v)
{
         if ($valu === false | $valu < $v
         ) {$valu=$v;//assign v to valu
         $mxaimum = $k;
         }
}}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List