I try to transpose matrix by reference, but without success, the matrix in the main stays in the same state. what can I do?
p.s. the function must to be "void"
thank you!
public static void trans(int a[][]) {
int n = a.length;
int m = a[0].length;
int b[][] = new int[m][n];
for (int i = 0; i < b.length; i++) {
for (int j = 0; j < b[0].length; j++) {
b[i][j] = a[j][i];
}
}
a = b;
}
public static void main(String[] args) {
int a[][] = {{1,2,3},
{4,5,6}};
trans(a);
System.out.println("*****************************");
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[0].length; j++) {
System.out.print(a[i][j]+"\t");
}
System.out.println();
}
}