Working with 2D arrays is quite important. Here we will do swapping of columns in a 2D array. You are given a matrix M of r rows and c columns. You need to swap the first column with the last column.
The first line of input contains T, the number of testcases. T testcases follow. Each testcase contains two lines of input. The first line contains r and c, separated by a space. The next r lines contains c elements of the matrix, separated by spaces.
For each testcase, in a new line, print the modified matrix.
Since this is a function problem, you don't need to take any input. Just complete the provided function interchange(int , int ) that take rows and columns number as parameter.
1 <= T <= 100
1 <= r,c <= 100
1 2 3 4
4 3 2 1
6 7 8 9
4 2 3 1
1 3 2 4
9 7 8 6
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.