Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners transpose of matrix
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


sahabaj gayen
transpose of matrix
1 Answer(s)      3 years and 10 months ago
Posted in : Java Beginners


write a program in java to declare a square matrices 'A' or order n which is less than 20.allow in user to input only positive integers into the matrix and print the transpose of it.


Advertisement
View Answers

February 8, 2011 at 2:41 PM


Java Find Transpose of Matrix

import java.util.*;

public class Transpose {
        public static void main(String[] args) throws Exception {
                int rows, cols;
                int[][] matrix, tmatrix;
                Scanner input = new Scanner(System.in);
                System.out.print("Enter number of rows: ");
                rows = input.nextInt();
                System.out.print("Enter number of columns: ");
                cols = input.nextInt();
                matrix = new int[rows][cols];
                tmatrix = new int[cols][rows];
                System.out.println("Enter elements for Matrix");
                for (int i = 0; i < rows; i++) {
                        for (int j = 0; j < cols; j++) {
                                matrix[i][j] = input.nextInt();
                        }
                }
                for (int i = 0; i < rows; i++) {
                        for (int j = 0; j < cols; j++) {
                                tmatrix[i][j] = matrix[j][i];
                        }
                }
                System.out.println("Matrix is:");
                for (int i = 0; i < rows; i++) {
                        for (int j = 0; j < cols; j++) {
                                System.out.print(matrix[i][j] + " ");
                        }
                        System.out.println();
                }
                System.out.println("Its transpose is: ");
                for (int i = 0; i < cols; i++) {
                        for (int j = 0; j < rows; j++) {
                                System.out.print(tmatrix[i][j] + " ");
                        }
                        System.out.println();
                }
        }
}


Related Tutorials/Questions & Answers:
transpose of matrix
transpose of matrix  write a program in java to declare a square matrices 'A' or order n which is less than 20.allow in user to input only positive integers into the matrix and print the transpose
transpose matrix
integers into the matrix and print the transpose of it. for this program u r given answer but if i entered 2 by 3 matrix it will not give answer ple check it once...transpose matrix  write a program in java to declare a square
Advertisements
transpose
transpose  how to write transpose of a matrix a program
Java Transpose of a matrix
Java Transpose of a matrix In this section, you will learn how to determine the transpose of a matrix.The transpose of a matrix is formed by interchanging... of the transposed matrix. The transpose of A is denoted by AT. Through the following
matrix addition
matrix addition  hai
matrix addition
matrix addition  hai
matrix substraction
matrix substraction  hai
matrix substraction
matrix substraction  hai
matrix adddition
matrix adddition   how to write a program matrix addition in java
column matrix
column matrix  columan wise total matrix
column matrix
column matrix  columan wise total matrix
Matrix multiplication
Matrix multiplication  program to read the elements of the given two matrices of order n*n and to perform the matrix multiplication
Matrix Class
Matrix Class   A class to manage matrices and add them. Create in the driver class two objects of it and use the add method
Matrix Class
Matrix Class   A class to manage matrices and add them. Create in the driver class two objects of it and use the add method
Java, matrix
of matrix.   Hello Friend, Try this: import java.util.*; class...]; int[][] C = new int[2][2]; System.out.println("Enter elements for matrix...++){ A[i][j] = input.nextInt(); } System.out.println("Enter elements for matrix B
matrix determination in java
matrix determination in java  hai
matrix polynamial addtion
matrix polynamial addtion  hai
Magic Matrix in GUI
Magic Matrix in GUI  I want program in java GUI contain magic matrix for numbers
Parallel multiplication matrix in java
Parallel multiplication matrix in java  hello dear I need parallel multiply matrix in java algorithm to account speed up and efficiency great wishes
matrix calculator - Java Beginners
matrix calculator  hi..... can you help me in writing source code of matrix calculator in java... i know you are the best you can do it!!! show yourself
parallel dense matrix multiplication
parallel dense matrix multiplication  hi friends, i am a final year... using dense parallel matrix multiplication. I request you to kindly provide me a code for Parallel Matrix multiplication on distributed systems using Java
Matrix Addition using RMI in Java
Matrix Addition using RMI in Java  Source Code for Matrix Addition using RMI in Java
Javascript matrix error
Javascript matrix error  This function blows up (without an error) whenever it is called function valid(n){ //n is a number 0-9 if(board...; } } where board is a global 3x3 Array matrix var board = new Array(3
Matrix - Java Beginners
Matrix  give me the Matrix program   Hi friend, Code for Matrix Example in Java class MatrixExample{ public static void main(String[] args) { int array[][]= {{1,3,5},{2,4,6
The GE Matrix
The GE matrix was developed by Mckinsey in 1970s for General Electric in order to overcome the various disadvantages associated with the BCG matrix. Since then, GE Matrix has been successfully deployed as an alternative in marketing
code for multiplication of matrix in java using methods
code for multiplication of matrix in java using methods  code for multiplication of matrix in java using methods
The BCG Matrix
The BCG matrix also called the Growth share matrix, B-Box, B.C.G. analysis, Boston Box, Boston Matrix, Boston Consulting Group analysis, portfolio diagram... business units and product lines. In broader terms of management, the BCG matrix
finding the eigenvalues and eigenvector of n*n matrix in java
finding the eigenvalues and eigenvector of n*n matrix in java  Here...[][] {{4,3,1,2},{1,1,1,1},{1,2,1,1},{1,1,1,1} }; double t, c, s; int p, q, icount... = new double[2][2]; // makes V into a unit matrix V = new double[size][size
Java create Identity matrix
Java create Identity matrix In this tutorial, you will learn how to create an identity or unit matrix. An identity matrix is a square matrix, of size n x n... elements are zeros. Here, we are going to create the unit matrix of arbitrary
Ansoff Matrix
The Ansoff matrix or Ansoff Growth matrix is an effective marketing planning... growth strategy. According to the Ansoff matrix, a business growth depends upon... product in a new or existing market. Based on this, factor Ansoff matrix
 

 

 

DMCA.com