-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathtranspose.java
39 lines (38 loc) · 1012 Bytes
/
transpose.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.io.*;
class transpose
{
public static void main()throws IOException
{int m,n;
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the Limits");
m=Integer.parseInt(in.readLine());
n=Integer.parseInt(in.readLine());
int a[][]=new int[m][n];
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
System.out.println("Enter the values");
a[i][j]=Integer.parseInt(in.readLine());
}
}
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
System.out.print(a[i][j]+" ");
}
System.out.println();
}
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
if(i==j||j>i)
{
System.out.print(a[i][j]+" ");
}
}
}
}
}