I was hoping that someone could help me out with this. For our program, we are supposed to write the following function
int reportMaxima( double array[ ] [ NCOLS ], int nRows, int nCols, double xMin,
double xMax, double yMin, double yMax );
Finds and prints out cells in the array that correspond to local maxima, defined as
cells that are no lower than all neighboring cells. For most cells, there will be four
neighbors, but for cells on the edges or in the corners, there will be 3 or 2 neighbors
I know what the question asks but have no idea how to implement this in c++.
I know that there will be a couple of if statements within the function for the number of neighbors. My question is which loop you would use to find the values of the four neighboring cells. I'm thinking a for loop should be used but I can't see how I can actually use it. Any help would be appreciated.
I just now thought of using nested for loops. This is assuming that there are 4 neighboring cells.
Would something like this work?
for(i=0;i<1;i++)//for 1st neighboring cell on the top
for(j=0;j<2;j++;j++)// for the cell to the left and to the right of the cell in question
//some code to skip the cell in question. I don't know how to do this though.
for(k=0;k<1;k++)//for the cell below
Am I on the right track or way off here?