-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReverseArray.java
More file actions
37 lines (28 loc) · 824 Bytes
/
ReverseArray.java
File metadata and controls
37 lines (28 loc) · 824 Bytes
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
import java.util.Scanner;
class ReverseArray {
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
System.out.println("Enter the size of the array :");
int sizeOfArray=sc.nextInt();
System.out.println("Enter the array :");
int arr[]=new int[sizeOfArray];
for(int i=0;i<sizeOfArray;i++){
int x=sc.nextInt();
arr[i]=x;
}
System.out.println(" Reverse array : ");
reverse(arr,sizeOfArray);
}
public static void reverse(int ar[],int n){
/* while(low<high){
temp=ar[low];
ar[low]=ar[high];
ar[high]=temp;
low++;
high--;
} */
for(int i=ar.length-1;i>=0;i--){
System.out.println(ar[i]+ " ");
}
}
}