0
C++ matrix
An M × N matrix is given. Mirror its elements about the vertical axis of symmetry of the matrix (in this case, the columns with numbers 1 and N, 2 and N - 1, etc. will be swapped).
5 Answers
0
Where is your attempt?
0
i dont know how to do this, this is a task from university. i study remotely...
0
Saying you have 4 numbers for each row. You start the loop with index = 0, so you can access the 1st element of a row with arr[row][index]. What's the mirror of it? arr[row][3], because it's the last element.
arr[row][0] <-> arr[row][3]
arr[row][1] <-> arr[row][2]
You see the pattern? When index is increased by 1, the mirror of it i decreased by 1. When index is increased by N, the mirror of it is decreased by N. Let K be "the length of last element - 1". You can swap arr[row][index] with arr[row][K - index], while iterating the array to half with for(int index = 0 ; index <= K/2 ; index++)
0
can you write full program? please)
0
I didn't complete the code. You need to complete it yourself.
https://code.sololearn.com/cm0jLLGu0gJ2/?ref=app