Task1 bos
unknown
java
2 years ago
1.1 kB
8
Indexable
Scanner sc = new Scanner(Main.class.getResourceAsStream("Matrix.txt"));
int mmk = sc.nextInt();
for(int tc = 0;tc < mmk;tc++){
int r = sc.nextInt();
int c = sc.nextInt();
int [][] matrix = new int[r][c];
int [][] transposeMatrix = new int[c][r];
int val;
for(int i = 0; i < r;i++){
for(int j = 0;j < c;j++){
val = sc.nextInt();
matrix[i][j] = val;
transposeMatrix[j][i] = val;
}
}
System.out.println("M:");
for(int i = 0;i<r;i++){
for(int j = 0;j < c;j++){
System.out.print(matrix[i][j] + "\t");
}
System.out.println();
}
System.out.println("M':");
for(int i = 0;i<c;i++){
for(int j = 0;j<r;j++){
System.out.print(transposeMatrix[i][j] + "\t");
}
System.out.println();
}
}Editor is loading...
Leave a Comment