I'm trying to vertically flip a 2D array, so I'm trying to turn this:
1 2 3 4 1
5 6 7 8 2
4 3 2 1 1
8 7 6 5 2
into
8 7 6 5 2
4 3 2 1 1
5 6 7 8 2
1 2 3 4 1
So far, I've got a nested for loop,
for (int i= 0; i<rows; i++)
{
for (int j = 0; j<columns; j++)
{
WillSmith[i, j] = arr[i,j];
}
}
With 'WillSmith' being the flipped array, but I keep getting the same array as I entered back.
I can't figure out what I'm doing wrong
EDIT: I've now swapped it to read arr[j,i], but now I get an error saying that I've overflowed the index. I need this to be able to work for non-square arrays, and since the array I'm testing isn't square, I can't just use newArray[i,j] = oldArray[j,i].