# Search for min and max values as columns position in array

• April 28th, 2011, 04:06 AM
susieferrari
Search for min and max values as columns position in array
Hi all,

I have an array such this simple example

Code Java:

```double[][]array = {{10.3,10.8,10.1,10.5},{9.3,9.8,9.1,9.5},{11.3,10.8,10.6,10.5}}; for(int i=0;i<array.length;i++){ for(int j=0;j<array[i].length;j++){ System.out.print(array[i][j]+" "); } System.out.println(""); }```

I need to find columns position for min and max values, no need to get the values itself.

I my example, max should always be at j[1] and min at j[2]: if not, print an error message such as: "Warning!Error at line 2".

Thanks for any help

Susie
• April 28th, 2011, 07:26 AM
KevinWorkman
Re: Search for min and max values as columns position in array
What have you tried? Where are you stuck? How would you do this "by hand", without a computer?
• April 28th, 2011, 07:32 AM
susieferrari
Re: Search for min and max values as columns position in array
Quote:

Originally Posted by KevinWorkman
How would you do this "by hand", without a computer?

Would seek row by row and chech if value at column[1] is greater than any other columns value in the same row.
Same for value at column[2] and there must be no lower value than this.

Is this correct?
• April 28th, 2011, 07:39 AM
KevinWorkman
Re: Search for min and max values as columns position in array
Well, do you know how to find the highest and lowest values in the array? I would start there.