import java.io.*;
class transpose
{
public static void main(String ar[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("ENTER THE NUMBER OF ROWS");
int r=Integer.parseInt(br.readLine());
System.out.println("ENTER THE NUMBER OF COLUMNNS");
int c=Integer.parseInt(br.readLine());
int matrix[][]=new int[r][c];
System.out.println("ENTER IN THE MATRIX");
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
matrix[i][j]=Integer.parseInt(br.readLine());
}
}
int transpose_matrix[][]=new int[c][r];
System.out.println("THE TRANSPOSE OF THE MATRIX IS");
for(int i=0;i<r;i++)
{
for(int z=0;z<c;z++)
{
transpose_matrix[z][i]=matrix[i][z];
}
}
for(int k=0;k<c;k++)
{
for(int x=0;x<r;x++)
{
System.out.println(transpose_matrix[k][x]);
}
}
}
}
class transpose
{
public static void main(String ar[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("ENTER THE NUMBER OF ROWS");
int r=Integer.parseInt(br.readLine());
System.out.println("ENTER THE NUMBER OF COLUMNNS");
int c=Integer.parseInt(br.readLine());
int matrix[][]=new int[r][c];
System.out.println("ENTER IN THE MATRIX");
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
matrix[i][j]=Integer.parseInt(br.readLine());
}
}
int transpose_matrix[][]=new int[c][r];
System.out.println("THE TRANSPOSE OF THE MATRIX IS");
for(int i=0;i<r;i++)
{
for(int z=0;z<c;z++)
{
transpose_matrix[z][i]=matrix[i][z];
}
}
for(int k=0;k<c;k++)
{
for(int x=0;x<r;x++)
{
System.out.println(transpose_matrix[k][x]);
}
}
}
}
No comments:
Post a Comment