public class Matrixtrans
{
public static void main (String[] args)
{
int [] [] a ={ {1,2,3} , {4,5,6} , {7,8,9} };
int m=3, n=3;
int [] [] c = new int [m][n];
for (int i=0; i<=m-1; i++)
{ for(int j=0; j<=n-1; j++)
c[j][i]=a[i][j];
}
for (int i=0; i<=m-1; i++)
{
for(int j=0; j<=n-1; j++)
System.out.printf("%d\t",c[i][j]);
System.out.println();
}
}
}
No comments:
Post a Comment
Thank You !