forked from codec-akash/DSA-PS-Java-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReverseOfArray.java
64 lines (52 loc) · 1.51 KB
/
ReverseOfArray.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package reverse.of.array;
/**
*
* @author shubhendu
*/
import java.util.Scanner;
public class ReverseOfArray {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner in=new Scanner(System.in);
int n=0,m=0,i,b;
System.out.println("enter the row size of the array");
System.out.println("enter the column size of the array");
n=in.nextInt();
m=in.nextInt();
int arr[][]=new int[2][2];
System.out.println("enter elements");
for(i=0;i<2;i++)
{
for(b=0;b<2;b++)
{
arr[i][b]=in.nextInt();
}
}
System.out.println("entered elements are:");
for(i=0;i<2;i++)
{
for(b=0;b<2;b++)
{
System.out.print(arr[i][b]+ " ");
}
System.out.println();
}
System.out.println("reverse of matrix is:");
for(i=2-1;i>=0;i--)
{
for(b=2-1;b>=0;b--)
{
System.out.print(arr[i][b]+ " ");
}
System.out.println();
}
}
}