Thread: finding max values in an array

  1. #1

    Question finding max values in an array

    Hi everyone. Im quite new to c programming so please bear with me. Im looking for a bit of advice. Ive written a program which accepts a 64x64 data file and writes it into an array. This works fine.

    Im now wanting to read each row in the array noting the position of the maximum value for each row and giving the coordinates of this value in terms of x and y with respect to the array.

    I was wondering if anyone could give me any clues to get me started with this or let me know any of the functions or commands I should be using.

    Any help would be greatly appreciated. Thanks.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Sounds pretty straight forward, the easiest way would be to read all of your data into the array and then go through each row of the array testing for max. When you find a value that is greater than max on that row, you save the index of the array and keep testing until you get to the end of the row.

    When you get to the end of the row, place the index of the largest value on that row into another array, reset max to 0 and start over on the next row.

    Then you have an array of indexes to use however you wish.

    My best code is written with the delete key.

  3. #3

    Thumbs up

    Thanks for that prelude. Can you tell me, what command to I use to test for max and how I would index the array?


  4. #4
    Registered User
    Join Date
    Sep 2001
    greater than sign >

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 02-08-2009, 09:26 PM
  2. putting values into an array
    By zdream8 in forum C Programming
    Replies: 15
    Last Post: 05-21-2008, 11:18 PM
  3. Checking maximum values for dynamic array...
    By AssistMe in forum C Programming
    Replies: 1
    Last Post: 03-21-2005, 12:39 AM
  4. How to read in empty values into array from input file
    By wpr101 in forum C++ Programming
    Replies: 5
    Last Post: 11-28-2002, 10:59 PM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 09:48 AM