Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Search for min and max values as columns position in array

  1. #1
    Junior Member susieferrari's Avatar
    Join Date
    Mar 2011
    Location
    Parma Italy
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts

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

    Hi all,

    I have an array such this simple example

    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


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default 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?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member susieferrari's Avatar
    Join Date
    Mar 2011
    Location
    Parma Italy
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Search for min and max values as columns position in array

    Quote Originally Posted by KevinWorkman View Post
    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?

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default 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.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Search for number in array and return index
    By Kevinius in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 24th, 2011, 12:00 AM
  2. [SOLVED] Help with array of Strings...Linear Search?
    By Stockholm Syndrome in forum Collections and Generics
    Replies: 4
    Last Post: March 22nd, 2011, 03:31 PM
  3. [SOLVED] Couldn't search for a string in an array.. Help please..
    By astrojunk in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 3rd, 2011, 10:47 PM
  4. need help inputting values into an array
    By pds8475 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 22nd, 2011, 09:47 PM
  5. Substitution of Values in Array
    By nyeung in forum Collections and Generics
    Replies: 2
    Last Post: October 26th, 2009, 08:02 PM