Hi i was asked in an interview about this question. I did google a lot after the interview but still i can’t get the clear solution. Can somebody tell me how i can return the (row,col) pairs (yes! return two values) using the function signature he mentioned.
void find(int A[][10], int m, int n, int target, int& row, int& col)
Your question title differs from what the actual question is.so not sure whether u want a searching method or how to return values from that function signature.
So not sure exactly what u need and whether the detail below is correct or not.
as the two variables row and col are references.justdo a search and populate the values inside the function.then you can use those two references in the place where you call.
for eg:
if you call the function as below from anywhere else:
i and j will be populated inside the function.and you can use them after the call.this implies the two values are returned from the function.