Computer Science, asked by anbarasusri2628, 1 month ago

Write a user defined function swapcolumn(A,R,C) to interchange the first column

elements with the last column elements ,second column with the second last and so

on, for a 2D integer array A, number of rows R, number of columns C passed as the

arguments to the function and also Print the resultant 2D list​

Answers

Answered by jmohanti1984
1

Explanation:

Difficulty Level : Easy

Last Updated : 19 Apr, 2021

Given a 4 x 4 matrix, the task is to interchange the elements of first and last columns and show the resulting matrix.

Examples:

Input:

8 9 7 6

4 7 6 5

3 2 1 8

9 9 7 7

Output:

6 9 7 8

5 7 6 4

8 2 1 3

7 9 7 9

Input:

9 7 5 1

2 3 4 1

5 6 6 5

1 2 3 1

Output:

1 7 5 9

1 3 4 2

5 6 6 5

1 2 3 1

Recommended: Please try your approach on {IDE} first, before moving on to the solution.

The approach is very simple, we can simply swap the elements of first and last column of the matrix in order to get the desired matrix as output.

Below is the implementation of the above approach :

Similar questions