Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Matrix-transposition/Java/matrix-transposition.java
Normal file
19
Task/Matrix-transposition/Java/matrix-transposition.java
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import java.util.Arrays;
|
||||
public class Transpose{
|
||||
public static void main(String[] args){
|
||||
double[][] m = {{1, 1, 1, 1},
|
||||
{2, 4, 8, 16},
|
||||
{3, 9, 27, 81},
|
||||
{4, 16, 64, 256},
|
||||
{5, 25, 125, 625}};
|
||||
double[][] ans = new double[m[0].length][m.length];
|
||||
for(int rows = 0; rows < m.length; rows++){
|
||||
for(int cols = 0; cols < m[0].length; cols++){
|
||||
ans[cols][rows] = m[rows][cols];
|
||||
}
|
||||
}
|
||||
for(double[] i:ans){//2D arrays are arrays of arrays
|
||||
System.out.println(Arrays.toString(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue