import javax.swing.JOptionPane;
public class transposeofarray
{
public static void main(String[] args) {
int [][]a= new int[3][3];
int i,j;
System.out.print("enter elements of matrix A");
for( i=0; i<=2; i++)
{
for(j=0; j<=2; j++)
{
a[i][j]=Integer.parseInt(JOptionPane.showInputDialog(" "));
}
}
System.out.print("\nA= ");
for( i=0; i<=2; i++)
{
System.out.print("\n");
for(j=0; j<=2; j++)
{
System.out.print(a[i][j]);
}
}
System.out.print("\n transpose is ");
for( i=0; i<=2; i++)
{
System.out.print("\n");
for(j=0; j<=2; j++)
{
System.out.print(a[j][i]);
}
}
}
}
public class transposeofarray
{
public static void main(String[] args) {
int [][]a= new int[3][3];
int i,j;
System.out.print("enter elements of matrix A");
for( i=0; i<=2; i++)
{
for(j=0; j<=2; j++)
{
a[i][j]=Integer.parseInt(JOptionPane.showInputDialog(" "));
}
}
System.out.print("\nA= ");
for( i=0; i<=2; i++)
{
System.out.print("\n");
for(j=0; j<=2; j++)
{
System.out.print(a[i][j]);
}
}
System.out.print("\n transpose is ");
for( i=0; i<=2; i++)
{
System.out.print("\n");
for(j=0; j<=2; j++)
{
System.out.print(a[j][i]);
}
}
}
}
output:
enter elements of matrix A
1
2
3
4
5
6
7
8
9
A=
123
456
789
transpose is
147
258
369
No comments:
Post a Comment
SAY HELLO!!