Task 1
unknown
java
a year ago
889 B
5
Indexable
Scanner sc = new Scanner(Main.class.getResourceAsStream("Matrix.txt")); int nm = sc.nextInt(); for(int tc = 0;tc < nm;tc++){ int row = sc.nextInt(); int column = sc.nextInt(); int [][] matrix = new int[row][column]; int [][] transposeMatrix = new int[column][row]; int val; for(int i = 0; i < row;i++){ for(int j = 0;j < column;j++){ val = sc.nextInt(); matrix[i][j] = val; transposeMatrix[j][i] = val; } } System.out.println("M:"); for(int i = 0;i<row;i++){ for(int j = 0;j < column;j++){ System.out.print(matrix[i][j] + "\t"); } System.out.println(); } System.out.println("M':"); for(int i = 0;i<column;i++){ for(int j = 0;j<row;j++){ System.out.print(transposeMatrix[i][j] + "\t"); } System.out.println(); } }
Editor is loading...
Leave a Comment