What the program is supposed to do:
Write a program which builds two dimensional array ( n x n matrix ) with the dimentions entered by the user, populates the array with random numbers from 0 to 9, builds 2 transpose matrixes (using both diagonals), and displays Them all.
For example,
Enter a matrix size: 4

For testing it will be easier to talk about the elements in the array if they were all unique. The code I posted in post#4 will generate all unique numbers.

To see what the code is doing add a println statement inside the inner for loop that prints out all the values involved: both indexes for the source element, the content of the source element, both indexes for the target element and the content of the target element. Seeing those 6 values will help you understand what the code is doing.

December 9th, 2013, 09:11 PM

namenamename

Re: 2D array problem

Quote:

Originally Posted by Norm

Can you explain what is wrong with the output?

A suggestion for testing. Make the changes you see here on the three lines with comments: