Contour

Given a two-dimensional rectangular array of NxM numbers. Find the smallest number in the first column or last row.
Any ideas how to find the smallest number ?

I did the array but no idea about how to get the smallest number in the first column or last row.






Last edited on
The "first column" is every index x[0][0] through x[0][m-1].
The "last row" is every index x[n-1][0] through x[n-1][m-1].

Make two more nested i/j for loops -- one that iterates over the last row, another that iterates over the last column. Keep a "min number so far" variable. Inside the loop, if the current x[i][j] is less than the 'min number so far', set it as the new min number.
Last edited on
You also check that n, m entered are >= 2 and <= 10.
If n = m = 1 then x[0][0] is the answer to both questions.
Topic archived. No new replies allowed.