Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   How do i compare row and column in 2D array? (http://www.go4expert.com/forums/i-compare-row-column-2d-array-t27976/)

won212 7Mar2012 23:40

How do i compare row and column in 2D array?
 
Hi do any expert/programmer know how can I compare the same row with same column to derive the maximum value? For examples, column 1 will be comparing with row 1, column 2 will be comparing with row 2, column 3 with row 3 and so on...

I did some c++ coding but it didn't works.

I guess I do not know yet to use what method for comparing same column and same row together, what code can ensure this?

By the way, my error is I have a 5x5 array, my first to fourth looping manage to get the correct maximum value. How ever, for the last, 5th position which is comparing array[4][0] with [0][4], I got the correct maximum value but did not manage to get the correct position [][] of the maximum value.

Thanks.

xpi0t0s 8Mar2012 06:33

Re: How do i compare row and column in 2D array?
 
How exactly didn't it work? Post your code. What input did you give (if relevant); what output did you get, and what output did you expect?

won212 8Mar2012 07:38

Re: How do i compare row and column in 2D array?
 
Hi for example I wanted it to print the maximum value as well as the the position.

For example, this is my 5x5 matrix.

1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 1

To compare 1st row with 1st column and as follow,

my result should shown:

[4][0] - 21
[4][1] - 22
[4][2] - 23
[4][3] - 24
[3][4] - 24, it should have printed [4][3].

xpi0t0s 8Mar2012 14:01

Re: How do i compare row and column in 2D array?
 
OK, but post your code as well, because I can't see where you went wrong if I can't see your code.

won212 8Mar2012 14:13

Re: How do i compare row and column in 2D array?
 
Hi sorry, manage to solve this afternoon, thanks for helping anyway! ^^


All times are GMT +5.5. The time now is 00:03.