Searching 2d array via Rows

The Task:
-----------------------
int findFirstInRow(int rowNum, double value)      Search the specified row for the first occurrence of value.
                              When you find the first occurrence of value, return the column
                                        number at which it is located.  If you do not find value in
                              the row, return -1 to indicate this.

The Question:
-----------------------
I've searched arrays before, but have no guidance on 2d arrays and specifying a specific row.  How do I approach breaking this down.  Algorithms plz.
smkJackstrawAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
objectsCommented:
A 2d array is an array of arrays, so get the array for a specific row you would use:

double[][] M = ...;   // the 2-d array
double[] row = M[rowNum];
0
 
smkJackstrawAuthor Commented:
Wouldn't the rows and column be integers?  Where as the value in any index be a double.


Would this be specified: double[][] M = M[int rowNum][0];




0
All Courses

From novice to tech pro — start learning today.