forked from ritikkhatana79020/Hacktoberfest2020
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrange.java
More file actions
47 lines (47 loc) · 1.03 KB
/
Arrange.java
File metadata and controls
47 lines (47 loc) · 1.03 KB
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
40
41
42
43
44
45
46
47
import java.util.*;
class square
{
public static void main()
{
Scanner in=new Scanner(System.in);
int a[][];
int m,n,i,j,temp=0;
System.out.println("Enter array size");
m=in.nextInt();
n=in.nextInt();
a=new int[m][n];
System.out.println("Enter "+m*n+" values:");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
a[i][j]=in.nextInt();
}
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
System.out.print(a[i][j]+"\t");
}
System.out.println();
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
temp=a[i][j];
a[i][j]=a[m-1][j];
a[m-1][j]=temp;
}
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
System.out.print(a[i][j]+"\t");
}
System.out.println();
}
}
}