0% found this document useful (0 votes)
14 views2 pages

Transpose Matrix Great

java transpose matrix

Uploaded by

amansirdav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Transpose Matrix Great

java transpose matrix

Uploaded by

amansirdav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

import java.io.

*;
class trans
{
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int arr1[][]=new int[3][3];
int arr2[][]=new int[3][3];
int i,j;
System.out.println(" ENTER THE ELEMENTS ");
System.out.println("********************** ");
for(i=0;i<3;i++)
{
System.out.println("elements for the "+(i+1)+" row ");
for(j=0;j<3;j++)
{
System.out.println("enter element no "+(j+1));
arr1[i][j]=Integer.parseInt(br.readLine());
}
}
System.out.println("********************** ");
System.out.println("********************** ");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
arr2[j][i]=arr1[i][j];
}
}
System.out.println(" THE ORIGINAL ARRAY ");
System.out.println("********************** ");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
System.out.print(arr1[i][j]+"\t");
}
System.out.println();
}

System.out.println(" THE TRANSPOSE ARRAY ");


System.out.println("********************** ");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
System.out.print(arr2[i][j]+"\t");
}
System.out.println();
}
}
}
Output

**********************
**********************
THE ORIGINAL ARRAY
**********************
12 34 56
88 90 78
12 67 98

THE TRANSPOSE ARRAY


**********************
12 88 12
34 90 67
56 78 98

You might also like