transpose of a matrix java

Solutions on MaxInterview for transpose of a matrix java by the best coders in the world

showing results for - "transpose of a matrix java"
Syrine
29 Sep 2020
1import java.util.Scanner;
2public class MatrixTransposeInJava
3{
4   public static void main(String[] args)
5   {
6      int[][] arrGiven = {{2,4,6},{8,1,3},{5,7,9}};	    
7      // another matrix to store transpose of matrix  
8      int[][] arrTranspose = new int[3][3];	    
9      // transpose matrix code  
10      for(int a = 0; a < 3; a++)
11      {    
12         for(int b = 0; b < 3; b++)
13         {    
14            arrTranspose[a][b] = arrGiven[b][a];  
15         } 
16      }	  
17      System.out.println("Before matrix transpose: ");  
18      for(int a = 0; a < 3; a++)
19      {    
20         for(int b = 0; b < 3; b++)
21         {    
22            System.out.print(arrGiven[a][b] + " ");    
23         } 
24         System.out.println();
25      }    
26      System.out.println("After matrix transpose: ");  
27      for(int a = 0; a < 3; a++)
28      {    
29         for(int b = 0; b < 3; b++)
30         {    
31            System.out.print(arrTranspose[a][b] + " ");    
32         } 
33         System.out.println();
34      }
35   }
36}
Lela
29 Jul 2019
1  //Transpose a Matrix
2
3  for (int row = 0; row < matrix.length; row++) {
4    
5   for (int col = row; row < matrix[row].length; col++) 
6   {
7    	// Swap 
8     	int data = matrix[row][col];
9    	matrix[row][col] = matrix[col][row];
10   		matrix[col][row] = data;
11   }
12  
13  }
Giacomo
13 Feb 2018
1for (int row = 0; row < matrix.length; row++) {
2    
3   for (int col = row; col < matrix[row].length; col++) 
4   {
5    	// Swap 
6     	int data = matrix[row][col];
7    	matrix[row][col] = matrix[col][row];
8   		matrix[col][row] = data;
9   }
10  
11  }
queries leading to this page
java how to transpose a matrixjava code to get matrix transposetranspose of a matrix code in javajava transpose one object to anotherwrite a program for finding the transpose of a 3 x3 matrix in javajava program to transpose a matrixfind transpose of a matrix in javainplace transpose of matrix javatranspose matrix in place javatranspose of matrix in java inplacetranspose of matrix in java using functionjava transpose matrixmatrix transpose java codetranspose of a matrix program in javatranspose of a matrixin javatranspose a matrix in javatranspose matrix java program in java in a single matrixtranspose of a matrix in java without using second matrixtranspose of a matrix in ajvatranspose codefind transpose of a matrix javatranspose of a given matrix javajava code to transpose a matrixwrite a java program to perform transpose of a matrixtranspose matrix javatrnaspose matrix javaprogram to transpose a matrix in javatranspose of matrix in javatranspose function of a matrix in javajava matrix transposejava program to find the transpose of a given matrixwrite pseudo code for input matrix to compact form 2c simple transpose and fast transposetranspose a matrix javatranspose of a matrix with user inpurt in javatransposing a 2d array math vector in javatranspose a matrix c 2b 2bdisplay the transpose of a given matrix javatrampose matix in javareverse a matrix in javatranspose of a 3x3 matrix in javatranspose of a matrix using rmi in javatranspose of a matrix javahow to do transpose of matrix javahow to create a transpose of a matrix javatranspose of matrix javatranspose of a matrix in javajava program to find the transpose of a given matrix transpose in javajava function to transpose a matrixfunction to transpose a matrix in javatranspose of a square matrix coding blocksjava program to find transpose of a matrixhow to find transpose of matrix in javaprint transpose of a matrix in javatransposing a matrix in javahow to transpose a matrix in javatranspose matrix in javajava program for transpose matrixmatrix transpose in javamatrix transpose javatranspose a matrix in javwrite a program to find the transpose of a given matrix in javatranspose matrix code javatransponierte matrix javamatrix transpose codereturn a two dimensional matrix of integers obtained from multiplication of all increment matrix and its transposetranspose of a matrix java