Timer is Running

Matrix Interchange
Submissions: 14300   Accuracy:


  Difficulty: Easy   Marks: 2

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.

Input Format:
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.

Output Format:
For each testcase, in a new line, print the modified matrix.

Your Task:
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


3 4
1 2 3 4
4 3 2 1
6 7 8 9
4 2 3 1
1 3 2 4
9 7 8 6

** For More Input/Output Examples Use 'Expected Output' option **

Author: Soul_xhacker

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.

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.