Rotation of 2d Matrix
Rotation of 2d Matrix
of columns such that both M and N must be greater than 2 and less than10. Allow the user to input integers into this
matrix. Display appropriate error message for an invalid input.
Example 1
INPUT: M =3
N=4
Example 2
INPUT: M =4
N=3
Example 3
INPUT: M = 2
N= 3
import java.util.Scanner;
class MATRIX_ROTATION
{
int arr[][];
int copy[][];
int row_limit;
int col_limit;
/*Display the Original Matrix which we have taken from the User*/
System.out.println("\n\tThe Matrix is : ");
for(int i=0;i<row_limit;i++)
{
for(int j=0;j<col_limit;j++)
{
System.out.print("\t"+arr[i][j]);
}
System.out.println();
}}
}
}
OUTPUT